예제 #1
0
파일: Region.cs 프로젝트: kaluluosi/Sugoi
 /// <summary>
 /// 如果Region是从AppWin中创建的,那么就以appwin的客户区为区域。
 /// </summary>
 /// <param name="appWin"></param>
 public Region(Window appWin)
 {
     this.appWin = appWin;
     X1 = Y1 = 0;
     X2 = appWin.ClientSize.Width;
     Y2 = appWin.ClientSize.Height;
 }
예제 #2
0
 public static void MyClassInitialize(TestContext testContext)
 {
     string pic = @"game.bmp";
     app = Process.Start(@"C:\WINDOWS\system32\mspaint.exe",pic);
     Thread.Sleep(500);
     win = Window.FindWindow("game.bmp");
 }
예제 #3
0
파일: IR.cs 프로젝트: kaluluosi/Sugoi
 /// <summary>
 /// 绑定dm对象的构造函数
 /// </summary>
 /// <param name="dm"></param>
 public IR(Window win)
 {
     this.win = win;
 }
예제 #4
0
 public void Case_FindChildrenNotExisted()
 {
     Window win = new Window(0);
     List<Window> windows = win.FindChildren("flakfl;jfsaljf",option:FilterOption.Title);
     Assert.IsNull(windows);
 }
예제 #5
0
        public void Case_FindChildrenExisted()
        {
            Window win = new Window(0);
            List<Window> windows = win.FindChildren("记事本");
            Assert.AreNotEqual(windows.Count, 0);

            bool existed = false;
            foreach(var w in windows) {
                if(w.Title.Contains("记事本")) {
                    existed = true;
                }
            }

            Assert.IsTrue(existed,"目标窗口不存在");
        }
예제 #6
0
파일: Window.cs 프로젝트: kaluluosi/Sugoi
 /// <summary>
 /// 获取子窗口,这个方法一般没什么用,即使有这方面需求也建议重新封装一个更具体的。
 /// </summary>
 /// <param name="option">操作选项</param>
 /// <returns></returns>
 public Window GetWindow(Option option = Option.Parent)
 {
     Window win = new Window(dm.GetWindow(Hwnd, (int)option));
     return win;
 }
예제 #7
0
파일: Window.cs 프로젝트: kaluluosi/Sugoi
 /// <summary>
 /// 查找最符合类名或者标题名的顶层可见窗口
 /// 例如:存在窗口 "大漠插件综合工具",那么查找"大漠"也能找到这个窗口
 /// </summary>
 /// <param name="title">标题名</param>
 /// <param name="className">窗口类名</param>
 /// <param name="parent">父窗口</param>
 /// <returns>窗口</returns>
 public static Window FindWindow(string title, string className = "", Window parent = null)
 {
     int hwnd = 0;
     if (parent == null) {
         hwnd = Dm.Default.FindWindow(className, title);
     }
     else {
         hwnd = Dm.Default.FindWindowEx(parent.Hwnd, className, title);
     }
     return hwnd > 0 ? new Window(hwnd) : null;
 }
예제 #8
0
파일: Window.cs 프로젝트: kaluluosi/Sugoi
 /// <summary>
 /// 根据指定条件,枚举系统中符合条件的窗口,可以枚举到按键自带的无法枚举到的窗口
 /// </summary>
 /// <param name="paren">父窗口</param>
 /// <param name="title">标题</param>
 /// <param name="className">窗口类名</param>
 /// <param name="option">过滤</param>
 /// <returns>所有窗口</returns>
 public static List<Window> EnumWindow(Window paren, string title = "", string className = "", FilterOption option = FilterOption.Default)
 {
     string allHwnds = Dm.Default.EnumWindow(paren.Hwnd, title, className, (int)option);
     return HwndString2Window(allHwnds);
 }
예제 #9
0
파일: Ocr.cs 프로젝트: kaluluosi/Sugoi
 /// <summary>
 /// 绑定dm对象的构造函数
 /// </summary>
 /// <param name="dm"></param>
 public Ocr(Window win)
 {
     this.win = win;
 }
예제 #10
0
파일: Sugoi.cs 프로젝트: kaluluosi/Sugoi
 /// <summary>
 /// 找到窗口并绑定
 /// </summary>
 /// <param name="title"></param>
 /// <param name="mode"></param>
 public void BindingWindow(string title, string mode)
 {
     appWin = Window.FindWindow(title);
     if (appWin == null) throw new Exception("Binding window fail.Can't find " + title);
     switch (mode) {
         case "Foreground":
             appWin.BindingDmsoft(BindingInfo.DefaultForeground);
             break;
         case "Background":
             appWin.BindingDmsoft(BindingInfo.DefaultBackground);
             break;
     }
     if (appWin.IsBinding == false) throw new Exception("Binding window fail.Can't bind mode " + mode);
 }
예제 #11
0
파일: Sugoi.cs 프로젝트: kaluluosi/Sugoi
 public void RunAndGetAppRegion(string exePath,string arguments="",string mode = "Foreground")
 {
     RunApp(exePath,arguments);
     Thread.Sleep(1000);
     appWin = new Window(app.MainWindowHandle.ToInt32());
     switch (mode) {
         case "Foreground":
             appWin.BindingDmsoft(BindingInfo.DefaultForeground);
             break;
         case "Background":
             appWin.BindingDmsoft(BindingInfo.DefaultBackground);
             break;
     }
     if (appWin.IsBinding == false) throw new Exception("Binding window fail.Can't bind mode " + mode);
 }
예제 #12
0
파일: Keyboard.cs 프로젝트: kaluluosi/Sugoi
 /// <summary>
 /// 绑定dm对象的构造函数
 /// </summary>
 /// <param name="dm"></param>
 public Keyboard(Window win)
 {
     this.win = win;
 }
예제 #13
0
파일: Mouse.cs 프로젝트: kaluluosi/Sugoi
 public Mouse(Window win)
 {
     this.win = win;
 }