Example #1
0
 public static void DoubleClick(Interactor intr, int xCoord, int yCoord)
 {
     intr.Log(LogEntryType.Trace, "Double-clicking at ({0},{1}).", xCoord, yCoord);
     intr.ExecuteStatement("SendEvent { Click " + xCoord + ", " + yCoord + ", 0 }");
     intr.Wait(10);
     intr.ExecuteStatement("SendEvent { Click 2 }");
 }
Example #2
0
 public static void DoubleClick(Interactor intr, int xCoord, int yCoord)
 {
     intr.Log(LogEntryType.Trace, "Double-clicking at ({0},{1}).", xCoord, yCoord);
     intr.ExecuteStatement("SendEvent { Click " + xCoord + ", " + yCoord + ", 0 }");
     intr.Wait(10);
     intr.ExecuteStatement("SendEvent { Click 2 }");
 }
Example #3
0
 public static void WindowKillTitle(Interactor intr, string windowTitle)
 {
     string param = windowTitle;
     intr.ExecuteStatement("WinClose, " + param);
     intr.ExecuteStatement("WinClose, " + windowTitle);
     intr.ExecuteStatement("WinKill, " + param);
     intr.ExecuteStatement("WinKill, " + windowTitle);
 }
Example #4
0
 // Need to figure these two out and simplify...
 public static void WindowKill(Interactor intr, string windowExe)
 {
     string param = string.Format("ahk_exe {0}", windowExe);
     intr.ExecuteStatement("WinClose, " + param);
     intr.ExecuteStatement("WinClose, " + windowExe);
     intr.ExecuteStatement("WinKill, " + param);
     intr.ExecuteStatement("WinKill, " + windowExe);
 }
Example #5
0
 public static void WindowKillClass(Interactor intr, string windowClass)
 {
     string param = string.Format("ahk_class {0}", windowClass);
     intr.ExecuteStatement("WinClose, " + param);
     intr.ExecuteStatement("WinClose, " + windowClass);
     intr.ExecuteStatement("WinKill, " + param);
     intr.ExecuteStatement("WinKill, " + windowClass);
 }
Example #6
0
        public static void WindowKillTitle(Interactor intr, string windowTitle)
        {
            string param = windowTitle;

            intr.ExecuteStatement("WinClose, " + param);
            intr.ExecuteStatement("WinClose, " + windowTitle);
            intr.ExecuteStatement("WinKill, " + param);
            intr.ExecuteStatement("WinKill, " + windowTitle);
        }
Example #7
0
        public static void WindowKillClass(Interactor intr, string windowClass)
        {
            string param = string.Format("ahk_class {0}", windowClass);

            intr.ExecuteStatement("WinClose, " + param);
            intr.ExecuteStatement("WinClose, " + windowClass);
            intr.ExecuteStatement("WinKill, " + param);
            intr.ExecuteStatement("WinKill, " + windowClass);
        }
Example #8
0
        // Need to figure these two out and simplify...
        public static void WindowKill(Interactor intr, string windowExe)
        {
            string param = string.Format("ahk_exe {0}", windowExe);

            intr.ExecuteStatement("WinClose, " + param);
            intr.ExecuteStatement("WinClose, " + windowExe);
            intr.ExecuteStatement("WinKill, " + param);
            intr.ExecuteStatement("WinKill, " + windowExe);
        }
Example #9
0
        // SendKeyWithMod <<<<< TODO: HANDLE DOUBLE MODIFIER (CTRL+ALT+X) >>>>>
        //		- Really cheesy and basically just hopes the caller has a valid keymod and key;
        public static void SendKeyWithMod(Interactor intr, string keyModIn, string keyIn, SendMode sendMode)
        {
            var modeStr = ResolveSendMode(sendMode);

            string keyModStr;
            string keyStr;

            if (!TryParseKeyMod(intr, keyIn, out keyStr, out keyModStr))
            {
                keyModStr = keyModIn;
                keyStr    = keyIn;
            }

            var keySeq = "{" + keyModStr + " down}{" + keyStr + "}{" + keyModStr + " up}";

            intr.Log(LogEntryType.Trace, "SendKeyWithMod(): Executing: '" + modeStr + keySeq + "' ...");
            intr.ExecuteStatement(modeStr + keySeq);

            //SendEvent(intr, "{Shift down}{Tab}{Shift up}");

            //var seq = sendModeStr + @" { " + keyMod + @" down }
            //Sleep 60
            //" + sendModeStr + @" { " + key + @" down }
            //Sleep 60
            //" + sendModeStr + @" { " + key + @" up }
            //Sleep 60
            //" + sendModeStr + @" { " + keyMod + @" up }
            //Sleep 60
            //";

            //intr.ExecuteStatement(keySeq);
        }
Example #10
0
 public static void WheelDown(Interactor intr, int repeats)
 {
     for (int c = 0; c < repeats; c++)
     {
         intr.ExecuteStatement("SendEvent { Click WheelDown }");
         intr.Wait(5);
     }
 }
Example #11
0
        public static void KeyPress(Interactor intr, string key, int duration)
        {
            //intr.ExecuteStatement("SendInput { " + key + " down }");
            //intr.Wait((int)duration + 180);
            //intr.ExecuteStatement("SendInput { " + key + " up }");
            //intr.Wait(20);

            string cmd = @"Send {" + key + @" down}
			Sleep "             + duration.ToString() + @"
			Send {"             + key + @" up}
			Sleep "             + duration.ToString() + @"
			"            ;

            intr.ExecuteStatement(cmd);
            intr.Wait(duration * 3);
        }
Example #12
0
        public static void KeyPress(Interactor intr, string key, int duration)
        {
            //intr.ExecuteStatement("SendInput { " + key + " down }");
            //intr.Wait((int)duration + 180);
            //intr.ExecuteStatement("SendInput { " + key + " up }");
            //intr.Wait(20);

            string cmd = @"Send {" + key + @" down}
            Sleep " + duration.ToString() + @"
            Send {" + key + @" up}
            Sleep " + duration.ToString() + @"
            ";

            intr.ExecuteStatement(cmd);
            intr.Wait(duration * 3);
        }
Example #13
0
        //public static void SendInput(Interactor intr, string key) {
        //	//intr.Wait(200);
        //	intr.ExecuteStatement("SendInput " + key);
        //	intr.Wait(50);
        //}

        //public static void SendPlay(Interactor intr, string keys) {
        //	intr.ExecuteStatement("SendPlay " + keys);
        //	intr.Wait(50);
        //}

        //public static void SendEvent(Interactor intr, string keys) {
        //	intr.ExecuteStatement("SendEvent " + keys);
        //	intr.Wait(50);
        //}

        public static void SendTest(Interactor intr, string key)
        {
            intr.Wait(3000);
            intr.ExecuteStatement("SendEvent " + key);
            intr.Wait(50);
        }
Example #14
0
        public static void WindowRun(Interactor intr, string windowExePath)
        {
            string runFolder = Path.GetDirectoryName(windowExePath);

            intr.ExecuteStatement("Run, " + windowExePath + ", " + runFolder);
        }
Example #15
0
 public static void Move(Interactor intr, int xCoord, int yCoord)
 {
     intr.Log(LogEntryType.Trace, "Moving mouse cursor to ({0},{1}).", xCoord, yCoord);
     intr.ExecuteStatement("SendEvent { Click " + xCoord + ", " + yCoord + ", 0 }");
 }
Example #16
0
        // SendKeyWithMod <<<<< TODO: HANDLE DOUBLE MODIFIER (CTRL+ALT+X) >>>>>
        //        - Really cheesy and basically just hopes the caller has a valid keymod and key;
        public static void SendKeyWithMod(Interactor intr, string keyModIn, string keyIn, SendMode sendMode)
        {
            var modeStr = ResolveSendMode(sendMode);

            string keyModStr;
            string keyStr;
            if (!TryParseKeyMod(intr, keyIn, out keyStr, out keyModStr)) {
                keyModStr = keyModIn;
                keyStr = keyIn;
            }

            var keySeq = "{" + keyModStr + " down}{" + keyStr + "}{" + keyModStr + " up}";

            intr.Log(LogEntryType.Trace, "SendKeyWithMod(): Executing: '"+ modeStr + keySeq + "' ...");
            intr.ExecuteStatement(modeStr + keySeq);

            //SendEvent(intr, "{Shift down}{Tab}{Shift up}");

            //var seq = sendModeStr + @" { " + keyMod + @" down }
            //Sleep 60
            //" + sendModeStr + @" { " + key + @" down }
            //Sleep 60
            //" + sendModeStr + @" { " + key + @" up }
            //Sleep 60
            //" + sendModeStr + @" { " + keyMod + @" up }
            //Sleep 60
            //";

            //intr.ExecuteStatement(keySeq);
        }
Example #17
0
 public static void WheelUp(Interactor intr, int repeats)
 {
     for (int c = 0; c < repeats; c++) {
         intr.ExecuteStatement("SendEvent { Click WheelUp }");
         intr.Wait(5);
     }
 }
Example #18
0
 public static void SendInput(Interactor intr, string key)
 {
     //intr.Wait(200);
     intr.ExecuteStatement("SendInput " + key);
     intr.Wait(20);
 }
Example #19
0
 public static void SendEvent(Interactor intr, string keys)
 {
     intr.ExecuteStatement("SendEvent " + keys);
     intr.Wait(20);
 }
Example #20
0
        public static void WindowActivate(Interactor intr, string windowExe)
        {
            string param = string.Format("ahk_exe {0}", windowExe);

            intr.ExecuteStatement("WinActivate, " + param);
        }
Example #21
0
 public static void SendInput(Interactor intr, string key)
 {
     //intr.Wait(200);
     intr.ExecuteStatement("SendInput " + key);
     intr.Wait(20);
 }
Example #22
0
 public static void Click(Interactor intr, int xCoord, int yCoord)
 {
     intr.Log(LogEntryType.Trace, "Clicking at ({0},{1}).", xCoord, yCoord);
     intr.ExecuteStatement("SendEvent { Click " + xCoord + ", " + yCoord + ", 1 }");
 }
Example #23
0
 public static void Move(Interactor intr, int xCoord, int yCoord)
 {
     intr.Log(LogEntryType.Trace, "Moving mouse cursor to ({0},{1}).", xCoord, yCoord);
     intr.ExecuteStatement("SendEvent { Click " + xCoord + ", " + yCoord + ", 0 }");
 }
Example #24
0
 public static void SendEvent(Interactor intr, string keys)
 {
     intr.ExecuteStatement("SendEvent " + keys);
     intr.Wait(20);
 }
Example #25
0
 public static void WindowMinimize(Interactor intr, string windowExe)
 {
     string param = string.Format("ahk_exe {0}", windowExe);
     intr.ExecuteStatement("WinMinimize, " + param);
 }
Example #26
0
 public static void WindowRun(Interactor intr, string windowExePath)
 {
     string runFolder = Path.GetDirectoryName(windowExePath);
     intr.ExecuteStatement("Run, " + windowExePath + ", " + runFolder);
 }
Example #27
0
 //public static void SendInput(Interactor intr, string key) {
 //    //intr.Wait(200);
 //    intr.ExecuteStatement("SendInput " + key);
 //    intr.Wait(50);
 //}
 //public static void SendPlay(Interactor intr, string keys) {
 //    intr.ExecuteStatement("SendPlay " + keys);
 //    intr.Wait(50);
 //}
 //public static void SendEvent(Interactor intr, string keys) {
 //    intr.ExecuteStatement("SendEvent " + keys);
 //    intr.Wait(50);
 //}
 public static void SendTest(Interactor intr, string key)
 {
     intr.Wait(3000);
     intr.ExecuteStatement("SendEvent " + key);
     intr.Wait(50);
 }
Example #28
0
 public static void Click(Interactor intr, int xCoord, int yCoord)
 {
     intr.Log(LogEntryType.Trace, "Clicking at ({0},{1}).", xCoord, yCoord);
     intr.ExecuteStatement("SendEvent { Click " + xCoord + ", " + yCoord + ", 1 }");
 }
Example #29
0
        /// <summary>
        /// Find an image and return it's upper left coordinate.
        /// </summary>
        /// This needs a crazy amount more error handling/reporting but it's just a huge pain. Most stuff is ignored.
        ///
        /// ErrorLevel is set to 0 if the image was found in the specified region,
        /// 1 if it was not found, or 2 if there was a problem that prevented the
        /// command from conducting the search(such as failure to open the image file
        /// or a badly formatted option).
        /// <param name="intr"></param>
        /// <param name="imgCode"></param>
        /// <param name="topLeft"></param>
        /// <param name="botRight"></param>
        /// <returns></returns>
        public static ImageSearchResult ImageSearch(Interactor intr, string imgCode, Point topLeft, Point botRight)
        {
            string imageFileName;

            if (!intr.ClientSettings.TryGetSetting(imgCode + "_ImageFile", "SearchRectanglesAnd_ImageFiles", out imageFileName))
            {
                imageFileName = imgCode + ".png";
                intr.ClientSettings.SaveSetting(imageFileName, imgCode + "_ImageFile", "SearchRectanglesAnd_ImageFiles");
            }

            string imageFilePath;

            if (File.Exists(Settings.Default.ImagesFolderPath + "\\" + imageFileName))
            {
                imageFilePath = Settings.Default.ImagesFolderPath + "\\" + imageFileName;
            }
            else
            {
                imageFilePath = SettingsForm.ProgramRootFolder + SettingsForm.BUILTIN_IMAGES_SUBPATH + "\\" + imageFileName;
            }

            intr.Log(new LogMessage(LogEntryType.Trace, "ImageSearch({0}): Searching for image: '{1}'"
                                    + " [TopLeft:{2} BotRight:{3}]",
                                    imgCode,
                                    imageFilePath,
                                    topLeft,
                                    botRight
                                    ));

            int outX       = 0;
            int outY       = 0;
            int errorLevel = 0;

            var imgSrcOptions = Settings.Default.ImageShadeVariation.ToString();

            intr.SetVar(OUTPUT_VAR_X, outX.ToString());
            intr.SetVar(OUTPUT_VAR_Y, outY.ToString());

            var statement = string.Format("ImageSearch, {0}, {1}, {2}, {3}, {4}, {5}, {6} {7}",
                                          OUTPUT_VAR_X, OUTPUT_VAR_Y, topLeft.X.ToString(), topLeft.Y.ToString(),
                                          botRight.X.ToString(), botRight.Y.ToString(), "*" + imgSrcOptions, imageFilePath);

            intr.Wait(20);
            intr.ExecuteStatement(statement);

            int.TryParse(intr.GetVar(OUTPUT_VAR_X), out outX);
            int.TryParse(intr.GetVar(OUTPUT_VAR_Y), out outY);
            int.TryParse(intr.GetVar(ERROR_LEVEL), out errorLevel);

            switch (errorLevel)
            {
            case 0:
                intr.Log(LogEntryType.Trace, "ImageSearch({0}): Found.", imgCode);
                return(new ImageSearchResult(true, new Point(outX, outY)));

            case 1:
                intr.Log(LogEntryType.Trace, "ImageSearch({0}): Not Found.", imgCode);
                return(new ImageSearchResult(false, new Point(outX, outY)));

            case 2:
                intr.Log(LogEntryType.Info, "ImageSearch(" + imgCode + "): Results: " +
                         " OutputVarX:" + intr.GetVar(OUTPUT_VAR_X) +
                         " OutputVarY:" + intr.GetVar(OUTPUT_VAR_Y) +
                         " ErrorLevel:" + intr.GetVar(ERROR_LEVEL));
                intr.Log(LogEntryType.Fatal, "ImageSearch(" + imgCode + "): FATAL ERROR. INVALID IMAGE FILE OR OPTION FORMAT. " +
                         "(Path: " + imageFilePath + ")");
                return(new ImageSearchResult(false, new Point(outX, outY)));

            default:
                intr.Log(LogEntryType.Fatal, "ImageSearch(" + imgCode + "): Not Found.");
                return(new ImageSearchResult(false, new Point(outX, outY)));
            }
        }
Example #30
0
        /// <summary>
        /// Find an image and return it's upper left coordinate.
        /// </summary>
        /// This needs a crazy amount more error handling/reporting but it's just a huge pain. Most stuff is ignored.
        /// 
        /// ErrorLevel is set to 0 if the image was found in the specified region, 
        /// 1 if it was not found, or 2 if there was a problem that prevented the 
        /// command from conducting the search(such as failure to open the image file 
        /// or a badly formatted option).
        /// <param name="intr"></param>
        /// <param name="imgCode"></param>
        /// <param name="topLeft"></param>
        /// <param name="botRight"></param>
        /// <returns></returns>
        public static ImageSearchResult ImageSearch(Interactor intr, string imgCode, Point topLeft, Point botRight)
        {
            string imageFileName;

            if (!intr.ClientSettings.TryGetSetting(imgCode + "_ImageFile", "SearchRectanglesAnd_ImageFiles", out imageFileName)) {
                imageFileName = imgCode + ".png";
                intr.ClientSettings.SaveSetting(imageFileName, imgCode + "_ImageFile", "SearchRectanglesAnd_ImageFiles");
            }

            string imageFilePath;

            if (File.Exists(Settings.Default.ImagesFolderPath + "\\" + imageFileName)) {
                imageFilePath = Settings.Default.ImagesFolderPath + "\\" + imageFileName;
            } else {
                imageFilePath = SettingsForm.ProgramRootFolder + SettingsForm.BUILTIN_IMAGES_SUBPATH + "\\" + imageFileName;
            }

            intr.Log(new LogMessage(LogEntryType.Trace, "ImageSearch({0}): Searching for image: '{1}'"
                + " [TopLeft:{2} BotRight:{3}]",
                imgCode,
                imageFilePath,
                topLeft,
                botRight
            ));

            int outX = 0;
            int outY = 0;
            int errorLevel = 0;

            var imgSrcOptions = Settings.Default.ImageShadeVariation.ToString();

            intr.SetVar(OUTPUT_VAR_X, outX.ToString());
            intr.SetVar(OUTPUT_VAR_Y, outY.ToString());

            var statement = string.Format("ImageSearch, {0}, {1}, {2}, {3}, {4}, {5}, {6} {7}",
                 OUTPUT_VAR_X, OUTPUT_VAR_Y, topLeft.X.ToString(), topLeft.Y.ToString(),
                 botRight.X.ToString(), botRight.Y.ToString(), "*" + imgSrcOptions, imageFilePath);

            intr.Wait(20);
            intr.ExecuteStatement(statement);

            int.TryParse(intr.GetVar(OUTPUT_VAR_X), out outX);
            int.TryParse(intr.GetVar(OUTPUT_VAR_Y), out outY);
            int.TryParse(intr.GetVar(ERROR_LEVEL), out errorLevel);

            switch (errorLevel) {
                case 0:
                    intr.Log(LogEntryType.Trace, "ImageSearch({0}): Found.", imgCode);
                    return new ImageSearchResult(true, new Point(outX, outY));
                case 1:
                    intr.Log(LogEntryType.Trace, "ImageSearch({0}): Not Found.", imgCode);
                    return new ImageSearchResult(false, new Point(outX, outY));
                case 2:
                    intr.Log(LogEntryType.Info, "ImageSearch(" + imgCode + "): Results: " +
                            " OutputVarX:" + intr.GetVar(OUTPUT_VAR_X) +
                            " OutputVarY:" + intr.GetVar(OUTPUT_VAR_Y) +
                            " ErrorLevel:" + intr.GetVar(ERROR_LEVEL));
                    intr.Log(LogEntryType.Fatal, "ImageSearch(" + imgCode + "): FATAL ERROR. INVALID IMAGE FILE OR OPTION FORMAT. " +
                        "(Path: " + imageFilePath + ")");
                    return new ImageSearchResult(false, new Point(outX, outY));
                default:
                    intr.Log(LogEntryType.Fatal, "ImageSearch(" + imgCode + "): Not Found.");
                    return new ImageSearchResult(false, new Point(outX, outY));
            }
        }