asmrobot
2019-11-25 2aeab450471cb80b59002da7da80faf251a0c4f4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using Emgu.CV;
using Emgu.CV.Structure;
using RichCreator.Utility;
using RichCreator.Utility.Captures;
using RichCreator.Utility.CV;
using RichCreator.Utility.InputControl;
using RichCreator.Utility.Structs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
 
namespace RichCreator.Utilitys
{
    public class GameUtils
    {
 
 
        /// <summary>
        /// 关闭所有弹出窗
        /// </summary>
        /// <param name="cancelToken"></param>
        /// <param name="gameRect"></param>
        /// <returns></returns>
        public static void CloseAllAlertWindowByEsc(CancellationToken cancelToken, ZTRectangle gameRect)
        {
            //关闭系统菜单
            Int32 counter = 5;
            while (!cancelToken.IsCancellationRequested && counter > 0)
            {
                G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.Escape);
                Thread.Sleep(1000);
                if (!DnfCVHelper.IsOpenSystemPanel(gameRect))
                {
                    break;
                }
                counter--;
            }
            
        }
 
        /// <summary>
        /// 关闭所有弹出窗
        /// </summary>
        /// <param name="cancelToken"></param>
        /// <param name="gameRect"></param>
        /// <returns></returns>
        public static void CloseAllAlertWindowByX(CancellationToken cancelToken, ZTRectangle gameRect)
        {
            while (!cancelToken.IsCancellationRequested)
            {
                //截图
                Image<Rgb, byte> image = ScreenCapture.Instance.CaptureScreenReturnImage();
 
                ZTRectangle closeButtonRect = ZTRectangle.Empty;
                if (!DnfCVHelper.GetAlertWindow(out closeButtonRect, image, gameRect))
                {
                    return;
                }
 
                G.Instance.InputControl.MoveToAndClick(closeButtonRect.GetCenterPoint());
                Thread.Sleep(500);
            }
        }
    }
}