/// <summary> /// Считывание позиции первого 2 класса /// </summary> /// <param name="title">Заголовок</param> /// <param name="text">Текст если есть</param> /// <param name="classing">Классы</param> /// <returns></returns> public void ControlGetPos2(string title, string text, string classing) { var param = AutoItX.ControlGetPos(title, text, classing); X2 = param.X; Y2 = param.Y; }
private void ChangeDownloadPath(string targetPath) { if (!Directory.Exists(targetPath)) { Directory.CreateDirectory(targetPath); } string currentPath = AutoItX.ControlGetText("[TITLE:Save As; CLASS:#32770]", "", "[CLASS:ToolbarWindow32; INSTANCE:4]"); if (!currentPath.Contains(targetPath)) { AutoItX.WinActivate("[TITLE:Save As; CLASS:#32770]", ""); IntPtr w = AutoItX.WinGetHandle("[TITLE:Save As; CLASS:#32770]", ""); IntPtr c = AutoItX.ControlGetHandle(w, "[CLASS:ToolbarWindow32; INSTANCE:4]"); Rectangle mainWindowPosition = AutoItX.WinGetPos(w); Rectangle refElementPosition = AutoItX.ControlGetPos(w, c); int startX = mainWindowPosition.X + refElementPosition.X + refElementPosition.Width - 10; int startY = mainWindowPosition.Y + refElementPosition.Y + refElementPosition.Height / 2; AutoItX.MouseMove(startX + 15, startY + 25); AutoItX.MouseClick("LEFT", startX + 15, startY + 25); AutoItX.Send("{BACKSPACE}"); AutoItX.AutoItSetOption("SendKeyDelay", GetRandomDelay(50)); AutoItX.Send(targetPath); Thread.Sleep(TimeSpan.FromSeconds(1)); AutoItX.Send("{ENTER}"); } }
private void ClickButton(IntPtr mainWindow, IntPtr refElement, int offsetX, int offsetY) { AutoItX.WinActivate(mainWindow); Rectangle mainWindowPosition = AutoItX.WinGetPos(mainWindow); Rectangle refElementPosition = AutoItX.ControlGetPos(mainWindow, refElement); int startX = mainWindowPosition.X + refElementPosition.X; int startY = mainWindowPosition.Y + refElementPosition.Y; ClickElement(startX, startY, offsetX, offsetY); }
private void ClickToFocus(IntPtr mainWindow, IntPtr refElement) { ClearTextBox(mainWindow, refElement); Rectangle mainWindowPosition = AutoItX.WinGetPos(mainWindow); Rectangle refElementPosition = AutoItX.ControlGetPos(mainWindow, refElement); int startX = mainWindowPosition.X + refElementPosition.X; int startY = mainWindowPosition.Y + refElementPosition.Y; AutoItX.WinActivate(mainWindow); ClickElement(startX, startY, 10, 10); }
Rectangle getCombo4Pos() { IntPtr hc = getComboBox4(); Rectangle rec_combo4 = AutoItX.ControlGetPos(_hwnd, hc); Rectangle rec_wnd = AutoItX.WinGetPos(_hwnd); IntPtr hmenu = getMenu(); Rectangle rec_menu = AutoItX.ControlGetPos(_hwnd, hmenu); int x = rec_wnd.X + rec_combo4.X; int y = rec_wnd.Y + rec_combo4.Y + rec_menu.Height; Rectangle rec = new Rectangle(x, y, rec_combo4.Width, rec_combo4.Height); return(rec); }
private static void Transfer() { var inputMainPanel = new IntPtr(); FillUpTransferForm(inputMainPanel); if (IsValidTransferForm()) { //SET TRANSFER PASSWORD var txtTransferpass = AutoItX.ControlGetHandle(_mainForm, "[CLASS:TCMBEdit]"); var txtTransferpassPosition = AutoItX.ControlGetPos(_mainForm, txtTransferpass); var elemementPositionX = _windowsPosition.X + txtTransferpassPosition.X; var elemementPositionY = _windowsPosition.Y + txtTransferpassPosition.Y; if (AutoItX.ControlFocus(_mainForm, txtTransferpass) != 1) { return; } Console.WriteLine("Focus on Transfer Password"); AutoItX.WinActivate(_mainForm); SimulateKey.SetForegroundWindow(txtTransferpass); Thread.Sleep(100); SimulateKey.ClearText(txtTransferpass); SimulateKey.SendText(txtTransferpass, Transferpassword); Console.WriteLine($"{Transferpassword}: Transfer Password Set"); Thread.Sleep(1000); Console.WriteLine("Confirm Transfer"); AutoItX.MouseClick("LEFT", elemementPositionX + 80, elemementPositionY + 80); Thread.Sleep(2000); if (ConfirmationMessageFindByClassName("TPbBaseMsgForm", new Tuple <int, int>(200, 180))) { Console.WriteLine("Confirmation Error On Transfer Transaction!"); } if (ConfirmationMessageFindByClassName("TErrorWithHelpForm", new Tuple <int, int>(200, 190))) { Console.WriteLine("Confirmation Error On Transfer Transaction!"); } } }
Rectangle getGridPos() { Rectangle rec_wnd = AutoItX.WinGetPos(_hwnd); IntPtr hmenu = getMenu(); Rectangle rec_menu = AutoItX.ControlGetPos(_hwnd, hmenu); IntPtr hgrid = getGrid(); Rectangle rec_grid = AutoItX.ControlGetPos(_hwnd, hgrid); int x = rec_wnd.X + rec_grid.X; int y = rec_wnd.Y + rec_grid.Y + rec_menu.Height; Rectangle rec = new Rectangle(x, y, rec_grid.Width, rec_grid.Height); return(rec); }
private void FillSameBankTransInfo(IntPtr mainFormWindow, RobotContext context) { IntPtr textToAccountName = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBStyleEdit; INSTANCE:2]"); EnterTextBox(mainFormWindow, textToAccountName, context.ToAccountName); IntPtr textToAccountNumber = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBStyleEdit; INSTANCE:3]"); Rectangle mainWindowPosition = AutoItX.WinGetPos(mainFormWindow); Rectangle refElementPosition = AutoItX.ControlGetPos(mainFormWindow, textToAccountNumber); int startX = mainWindowPosition.X + refElementPosition.X; int startY = mainWindowPosition.Y + refElementPosition.Y; int elementPossitionX = startX + 20; int elementPossitionY = startY + 20; AutoItX.MouseClick("LEFT", elementPossitionX, elementPossitionY); InputSimulatorUtils.EnterKeysByVirtualKeyboard(context.ToAccountNumber, true); //IntPtr textToAccountNumber = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBStyleEdit; INSTANCE:3]"); //EnterTextBox(mainFormWindow, textToAccountNumber, context.ToAccountNumber); IntPtr searchComboBoxToAccountCity = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBSearchComboBox; INSTANCE:1]"); SearchAndSelectComboBox(mainFormWindow, searchComboBoxToAccountCity, context.ToAccountCity); IntPtr textTransferAmount = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBStyleEdit; INSTANCE:4]"); EnterTextBox(mainFormWindow, textTransferAmount, context.WithdrawAmount); IntPtr textPostscript = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBStyleComboBox; INSTANCE:1]"); EnterComboBoxBox(mainFormWindow, textPostscript, context.BoTransactionId); ClickButton(mainFormWindow, 350, 640); // click 'Next' button int warningHappen1 = AutoItX.WinWaitActive("[CLASS:TPbBaseMsgForm]", "选择的收款方地址与收款方账户所属开户地不符", 10); if (warningHappen1 == AutoItXSuccess) { IntPtr warningPopWin1 = AutoItX.WinGetHandle("[CLASS:TPbBaseMsgForm]", "选择的收款方地址与收款方账户所属开户地不符"); ClickButton(warningPopWin1, 300, 150); } }
private static void DoLogIn(IntPtr mainForm, IntPtr txtpass) { var windowsLogPosition = AutoItX.WinGetPos(mainForm); var txtPassPosition = AutoItX.ControlGetPos(mainForm, txtpass); var btnLogInPossitionX = windowsLogPosition.X + txtPassPosition.X + 50; var btnLogInPossitionY = windowsLogPosition.Y + txtPassPosition.Y + 60; Console.WriteLine("Click Log In"); AutoItX.MouseClick("LEFT", btnLogInPossitionX, btnLogInPossitionY); if (AutoItX.WinActivate("[CLASS:TPbBaseMsgForm]") == 1) { Console.WriteLine("Invalid Password"); } if (AutoItX.WinActivate("错误") == 1) { Console.WriteLine("Authentication Key Is Required"); } }
private void SearchAndSelectComboBox(IntPtr mainWindow, IntPtr searchComboBox, string value) { Rectangle mainWindowPosition = AutoItX.WinGetPos(mainWindow); Rectangle refElementPosition = AutoItX.ControlGetPos(mainWindow, searchComboBox); int startX = mainWindowPosition.X + refElementPosition.X; int startY = mainWindowPosition.Y + refElementPosition.Y; int elementPossitionX = startX + 10; int elementPossitionY = startY + 10; AutoItX.MouseMove(elementPossitionX, elementPossitionY); AutoItX.MouseClickDrag("LEFT", elementPossitionX, elementPossitionY, elementPossitionX + 100, elementPossitionY + 30, 100); AutoItX.MouseDown(); AutoItX.MouseUp(); AutoItX.ClipPut(value); AutoItX.Send("^v"); AutoItX.MouseMove(elementPossitionX + 100, elementPossitionY + 70); AutoItX.MouseDown(); AutoItX.MouseUp(); Thread.Sleep(GetRandomDelay(100)); // stop to make sure the dropdown selected done }
private static void FillUpTransferForm(IntPtr inputMainPanel) { var toAccountNumber = "6214837694277025"; var toAccountName = "吕文斌"; //var fromAccountNumber = ""; //var fromAccountName = ""; var transactionReferenceId = "12345678912"; var transactionReference = "test Remarks"; var amount = "1"; //Click Transger if (AutoItX.WinActivate(_mainForm) != 1) { return; } WaitForTransferPage(); var inputMainPanelPosition = AutoItX.ControlGetPos(_mainForm, inputMainPanel); var elemementPositionX = _windowsPosition.X + inputMainPanelPosition.X; var elemementPositionY = _windowsPosition.Y + inputMainPanelPosition.Y; //Account Name AutoItX.WinActivate(_mainForm); AutoItX.AutoItSetOption("SendKeyDelay", GetRandomDelay(100)); var txttoAccount = AutoItX.ControlGetHandle(_mainForm, "[CLASS:Edit; INSTANCE:1]"); AutoItX.ControlSetText(_mainForm, txttoAccount, toAccountName); AutoItX.MouseClick("LEFT", elemementPositionX + 200, elemementPositionY + 35); Thread.Sleep(GetRandomDelay(1000)); //Account Number AutoItX.WinActivate(_mainForm); AutoItX.AutoItSetOption("SendKeyDelay", GetRandomDelay(100)); AutoItX.MouseClick("LEFT", elemementPositionX + 200, elemementPositionY + 75); AutoItX.Send(toAccountNumber); Thread.Sleep(GetRandomDelay(1000)); //Bank AutoItX.WinActivate(_mainForm); AutoItX.AutoItSetOption("SendKeyDelay", GetRandomDelay(100)); AutoItX.MouseClick("LEFT", elemementPositionX + 200, elemementPositionY + 120); Thread.Sleep(GetRandomDelay(1000)); //Amount AutoItX.WinActivate(_mainForm); AutoItX.AutoItSetOption("SendKeyDelay", GetRandomDelay(100)); AutoItX.MouseClick("LEFT", elemementPositionX + 200, elemementPositionY + 230); AutoItX.Send(amount); Thread.Sleep(GetRandomDelay(1000)); //transaction Remarks AutoItX.WinActivate(_mainForm); AutoItX.AutoItSetOption("SendKeyDelay", GetRandomDelay(100)); AutoItX.MouseClick("LEFT", elemementPositionX + 200, elemementPositionY + 285); AutoItX.Send(transactionReference); Thread.Sleep(GetRandomDelay(1000)); //transaction ID AutoItX.WinActivate(_mainForm); AutoItX.AutoItSetOption("SendKeyDelay", GetRandomDelay(100)); AutoItX.MouseClick("LEFT", elemementPositionX + 200, elemementPositionY + 335); AutoItX.Send(transactionReferenceId); Thread.Sleep(GetRandomDelay(1000)); AutoItX.WinActivate(_mainForm); AutoItX.AutoItSetOption("SendKeyDelay", GetRandomDelay(100)); AutoItX.MouseClick("LEFT", elemementPositionX + 200, elemementPositionY + 380); Thread.Sleep(GetRandomDelay(1000)); if (ConfirmationMessageFindByClassName("TPbBaseMsgForm", new Tuple <int, int>(285, 180))) { Console.WriteLine("Error FillUpTransferForm"); } }
public Rectangle ControlGetPos(string title = "", string text = "", string control = "") { return(AutoItX.ControlGetPos(title, text, control)); }
public Rectangle ControlGetPos(IntPtr winHandle, string control = "") { return(AutoItX.ControlGetPos(thiswindowHandle, ControlGetHandle(control))); }