Пример #1
0
        public bool ClickConnect()
        {
            try
            {
                //Start();
                if (au3 == null)
                {
                    au3 = new AutoItX3Lib.AutoItX3();
                }

                au3.WinActivate(APP_TITLE);
                Thread.Sleep(1000);

                int xx = au3.WinGetPosX(APP_TITLE);
                int yy = au3.WinGetPosY(APP_TITLE);
                int w  = au3.WinGetPosWidth(APP_TITLE);
                int h  = au3.WinGetPosHeight(APP_TITLE);
                //au3.MouseClick("left", xx + w/2, yy + h/2, 5, 5);
                au3.MouseClick("left", xx + w - 55, yy + 80, 1, 5);
                Thread.Sleep(5000);
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(false);
        }
Пример #2
0
        /// <summary>
        /// Key Press -> Send specified Key to window.
        /// </summary>
        /// <param name="popUpName">string : Name of popup to recover.</param>
        /// <param name="key"> string : Key to send.</param>
        private static void KeyPress(string popUpName, string key)
        {
            try
            {
                _objAutoit.WinActivate(popUpName, string.Empty); //Activate window.

                switch (key.ToLower())                           //Send Specified Key.
                {
                case "tab":
                    _objAutoit.Send("{TAB}");
                    break;

                case "space":
                    _objAutoit.Send("{SPACE}");
                    break;

                case "enter":
                    _objAutoit.Send("{ENTER}");
                    break;

                default:
                    _objAutoit.Send(key, 1);
                    break;
                }
            }
            catch (Exception e)
            {
                KryptonException.Writeexception(e.InnerException);
            }
        }
Пример #3
0
        static int i = 0;                                                       //our incrementer

        /// <summary>
        /// The entry point, or main thread / main loop, of our program
        /// </summary>

        static void Main(string[] args)
        {
            au3 = new AutoItX3Lib.AutoItX3();                                   //initialize our au3 class library

            au3.AutoItSetOption("WinTitleMatchMode", 4);                        //advanced window matching

            thread = new Thread(new ThreadStart(threadtest));                   //initialize and start our thread
            thread.Start();

            if (au3.WinExists("Untitled - Notepad", "") == 0)                   //if an Untitled - Notepad document doesn't exist
            {
                au3.Run(@"C:\WINDOWS\SYSTEM32\notepad.exe", "", au3.SW_SHOW);   //run notepad
            }
            else
            {
                au3.WinActivate("Untitled - Notepad", "");                      //otherwise activate the window
            }
            string hWnd = "";                                                   //let's use a window handle

            while (hWnd.Length == 0)                                            //try to get a handle to notepad until it succeeds
            {
                hWnd = au3.WinGetHandle("Untitled - Notepad", "");
            }

            while (au3.WinActive("handle=" + hWnd, "") == 0)                    //loop while it's not active
            {
                au3.WinActivate("handle=" + hWnd, "");                          //and activate it
                Thread.Sleep(100);
            }

            while (au3.WinExists("handle=" + hWnd, "") != 0)                    //while the window exists, loop
            {
                //send our incrementing variable, i, to notepad, with a trailing |
                au3.ControlSend("handle=" + hWnd, "", "Edit1", i.ToString() + "|", 0);

                i++;                                                            //increment i

                Thread.Sleep(100);                                              //short sleep so we don't burn CPU
            }

            //if the while loop exited--because there's no Untitled - Notepad--make the other thread stop executing
            threadshouldexecute = false;

            Console.Write("Press [ENTER] to continue...");                      //tell the user to press ENTER to quit
            Console.ReadLine();                                                 //pause until enter is pressed
        }
Пример #4
0
 public void Open()
 {
     autoIT.Run(application);
     autoIT.WinActivate(application_title);
     autoIT.WinWaitActive(application_title);
 }
Пример #5
0
        public static string activateCurrentBrowserWindow()
        {
            // try to switch to most recent browser window, if you can
            try
            {
                string winTitle = Driver.Title;
                AutoItX3Lib.AutoItX3 objAutoit = new AutoItX3Lib.AutoItX3();
                var windowList = (Object[,])objAutoit.WinList("[TITLE:" + winTitle + "; CLASS:IEFrame]");
                int windowCount = (int)windowList[0, 0];
                if (windowCount.Equals(1))
                {
                    //Setting window on top means you cannot manually switch to any other windows
                    //If you need IE clicks to be stable, this has to be done
                    objAutoit.WinSetOnTop(winTitle, "", 1);

                    //Activate window and set to focus
                    objAutoit.WinActivate(winTitle);
                }
            }
            catch (Exception)
            {
                // Ignore
            }
            return Property.HwndMostRecentWindow;
        }