Exemple #1
0
        static void AdvancedExport()
        {
            string title = "高级导出";

            int handle = AutoItX.WinWait(title, "", 10);

            if (handle == 0)
            {
                throw new InvalidOperationException("failed to find dialog for advance data exporting");
            }

            IntPtr hwnd = AutoItX.WinGetHandle(title, "");

            AutoItX.WinActivate(hwnd);

            IntPtr buttonAddObject      = AutoItX.ControlGetHandle(hwnd, "[CLASSNN:Button5]");
            IntPtr buttonBeginExport    = AutoItX.ControlGetHandle(hwnd, "[CLASSNN:Button7]");
            IntPtr buttonClose          = AutoItX.ControlGetHandle(hwnd, "[CLASSNN:Button8]");
            IntPtr comboBoxRight        = AutoItX.ControlGetHandle(hwnd, "[CLASSNN:ComboBox3]");
            IntPtr buttonGenerateHeader = AutoItX.ControlGetHandle(hwnd, "[CLASSNN:Button4]");

            AutoItX.ControlCommand(hwnd, buttonGenerateHeader, "Check", "");
            AutoItX.ControlCommand(hwnd, comboBoxRight, "SelectString", "前复权");

            AutoItX.Sleep(2000);

            AutoItX.ControlClick(hwnd, buttonClose);
        }
Exemple #2
0
        static void DownloadQuote()
        {
            string title = "盘后数据下载";

            int handle = AutoItX.WinWait(title, "", 10);

            if (handle == 0)
            {
                throw new InvalidOperationException("failed to find dialog for downloading quote");
            }

            IntPtr hwnd = AutoItX.WinGetHandle(title, "");

            AutoItX.WinActivate(hwnd);

            // select the "日线和实时行情数据" checkbox
            AutoItX.Send("{SPACE}");

            // click the download button
            IntPtr buttonDownload = AutoItX.ControlGetHandle(hwnd, "[CLASSNN:Button9]");

            AutoItX.ControlClick(hwnd, buttonDownload);

            AutoItX.Sleep(2000);

            // wait until the close button is enabled.
            IntPtr buttonClose = AutoItX.ControlGetHandle(hwnd, "[CLASSNN:Button10]");

            while (AutoItX.ControlCommand(hwnd, buttonClose, "IsEnabled", "") == "0")
            {
                AutoItX.Sleep(1000);
            }

            AutoItX.ControlClick(hwnd, buttonClose);
        }
Exemple #3
0
        private void CheckforGroupSelector(string windowTitle, string controlID)
        {
            string GroupdropdownHandle = AutoItX.ControlCommand(windowTitle, "", controlID, "IsVisible", "");

            if (Int16.Parse(GroupdropdownHandle) == 1) //If control isenabled, autoit will return 1
            {
                if (!string.IsNullOrEmpty(groupName))
                {
                    string defaultGroupName = AutoItX.ControlCommand(windowTitle, "", groupDropdown, "GetCurrentSelection", groupName); // get the default group name if any

                    if (defaultGroupName != groupName || string.IsNullOrEmpty(defaultGroupName))
                    {
                        AutoItX.ControlCommand(windowTitle, "", groupDropdown, "SelectString", groupName);
                        string selectedGroupName = AutoItX.ControlCommand(windowTitle, "", groupDropdown, "GetCurrentSelection", groupName);


                        if (selectedGroupName != groupName)
                        {
                            ShowErrorPopup($"Unable to find 'GROUP: {groupName}'. Check it in CONFIG file.");
                        }


                        //After selecting a value from dropdown, popup window becomes disbles.. wait till it becomes active again
                        WaitTillControlEnabled(loginWindowTitle, okButton);
                    }
                }
                else
                {
                    ShowErrorPopup($"Enter valid GROUP {groupName} inside CONFIG file");
                }
            }
        }
Exemple #4
0
        private void WaitTillControlEnabled(string windowTitle, string controlID)
        {
            stopwatch = new Stopwatch();
            stopwatch.Start();

            //wait till the control enable and also wait upto the waittime declared
            while (Int16.Parse(AutoItX.ControlCommand(windowTitle, "", controlID, "IsEnabled", "")) == 0 && stopwatch.Elapsed.Seconds <= waitTime)
            {
                AutoItX.Sleep(100);
            }
            stopwatch.Stop();
            AutoItX.Sleep(500); //Added this sleep for stability
        }
    static void Main(string[] args)
    {
        var buttonVisible = AutoItX.ControlCommand("Untitled - Notepad", "", "[CLASSNN:Edit1]", "IsVisible", "");

        //in your case it would be:
        //var buttonVisible = AutoItX.ControlCommand("Put the application title here", "", "[CLASSNN:AfxWnd90u21]", "IsVisible", "");

        if (buttonVisible == "1")
        {
            Console.WriteLine("Visible");
        }
        else
        {
            Console.WriteLine("Not visible");
        }
    }
Exemple #6
0
        private void CheckControlVisibility(string windowTitle, string controlID, string windowText = "")
        {
            var isControlVisible = AutoItX.ControlCommand(windowTitle, windowText, controlID, "IsVisible", "");

            if (controlID == disconnectButton)                                     //Disconnect VPN if its already connected
            {
                if (Int16.Parse(isControlVisible) == 1)                            //Autoit will return 1 if the control is visible
                {
                    AutoItX.ControlClick(domainWindowTitle, "", disconnectButton); //Uncomment this line if you need disconnect vpn if its already connected
                    WaitForWindow(domainWindowTitle, 10, "Ready to connect.");     //Close vpn window once it got disconnected successfully
                    AutoItX.WinClose(domainWindowTitle, "Ready to connect.");
                    Environment.Exit(0);
                }
            }
            else
            {
                if (Int16.Parse(isControlVisible) == 0) //Autoit will return 1 if the control is visible
                {
                    ShowErrorPopup($"CONTROL NOT VISIBLE\nwindowtitle={windowTitle}\ncontrolID={controlID}");
                }
            }
        }
Exemple #7
0
        private void ConnectToDomain()
        {
            WaitForWindow(domainWindowTitle);

            //Check all elements are visible in particular window
            CheckControlVisibility(domainWindowTitle, disconnectButton);
            CheckControlVisibility(domainWindowTitle, domainTextbox);
            CheckControlVisibility(domainWindowTitle, domainDropdown);

            //Check textbox value and select domain from dropdown
            string defaultDomainVal = AutoItX.ControlGetText(domainWindowTitle, "", domainTextbox);

            if (defaultDomainVal != domainName && string.IsNullOrEmpty(defaultDomainVal) == false)
            {
                AutoItX.ControlCommand(domainWindowTitle, "", domainDropdown, "AddString", domainName);
                AutoItX.ControlCommand(domainWindowTitle, "", domainDropdown, "SelectString", domainName);
            }
            else
            {
                AutoItX.ControlClick(domainWindowTitle, "", connectButton);
            }

            Console.WriteLine("-- Connecting to domain");
        }
 public string ControlCommand(string title, string text, string control, string command, string extra, int maxLen = 65535)
 {
     return(AutoItX.ControlCommand(title, text, control, command, extra, maxLen));
 }
 public string ControlCommand(string command, string extra, int maxLen = 65535, string control = "")
 {
     return(AutoItX.ControlCommand(thiswindowHandle, ControlGetHandle(control), command, extra, maxLen));
 }
Exemple #10
0
 public static string ControlCommand(string strTitle, string strText, string strControl, string strCommand, string strExtra)
 {
     return(AutoItX.ControlCommand(strTitle, strTitle, strControl, strCommand, strExtra));
 }