private RobotResult DoLogIn(RobotContext context) { try { IntPtr loginFormWindow = AutoItX.WinGetHandle(LoginFormTitle); IntPtr textPassBox = AutoItX.ControlGetHandle(loginFormWindow, "[CLASS:TCMBStyleEdit72]"); EnterLoginBox(loginFormWindow, textPassBox, context.LoginPassword); ClickButton(loginFormWindow, textPassBox, 70, 70); int warningHappen1 = AutoItX.WinWaitActive("[CLASS:TPbBaseMsgForm]", "", 10); //login password validate if (warningHappen1 == AutoItXSuccess) { string errorText = AutoItX.WinGetText("[CLASS:TPbBaseMsgForm]"); AutoItX.WinClose("[CLASS:TPbBaseMsgForm]"); return(RobotResult.Build(context, RobotStatus.ERROR, $"Login Failed, Error<{errorText.Trim()}>")); } WaitUtils.UntilWinActive(MainWindowTitle, MainWindowText); return(RobotResult.Build(context, RobotStatus.SUCCESS, "Login Success, Awesome!")); } catch (Exception e) { return(RobotResult.Build(context, RobotStatus.ERROR, e.Message)); } }
private RobotResult DoOpenClientApp(RobotContext context) { try { TryToKillOldProcess(context.MidasTransactionId); SimulateKey.MouseMove(500, 500); SimulateKey.MouseClick(500, 500); SimulateKey.MouseClick(500, 500); //Process process = new Process(); //process.StartInfo.FileName = LocaleEmulatorFileName; //process.StartInfo.WorkingDirectory = LocaleEmulatorWorkingDirectory; //process.StartInfo.Arguments = PersonalBankPortalPath; //process.Start(); Thread.Sleep(TimeSpan.FromSeconds(3)); return(RobotResult.Build(context, RobotStatus.SUCCESS, "Open Client App Success!")); } catch (Exception e) { return(RobotResult.Build(context, RobotStatus.ERROR, e.Message)); } }
private void FillOtp(IntPtr mainFormWindow, RobotContext context) { ClickButton(mainFormWindow, 550, 410); // click '获取短信验证码' button int warningHappen1 = AutoItX.WinWaitActive("[CLASS:TPbBaseMsgForm]", "选择通过短信方式获取验证码", 5); if (warningHappen1 == AutoItXSuccess) { IntPtr warningPopWin1 = AutoItX.WinGetHandle("[CLASS:TPbBaseMsgForm]", "选择通过短信方式获取验证码"); ClickButton(warningPopWin1, 250, 170); } int warningHappen2 = AutoItX.WinWaitActive("[CLASS:TPbBaseMsgForm]", "通过短信方式获取验证码的请求提交成功", 10); if (warningHappen2 == AutoItXSuccess) { IntPtr warningPopWin2 = AutoItX.WinGetHandle("[CLASS:TPbBaseMsgForm]", "通过短信方式获取验证码的请求提交成功"); ClickButton(warningPopWin2, 300, 160); } // wait to get OTP context.Otp = "6543210"; IntPtr textOtpBox = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBEdit; INSTANCE:1]"); EnterOtpBox(mainFormWindow, textOtpBox, context.Otp); ClickButton(mainFormWindow, 420, 610); // click 'Next' button Thread.Sleep(TimeSpan.FromSeconds(5)); }
public void Transfer(RobotContext context) { RobotResult transferResult = RobotResult.Default(context); var steps = AllSteps(); try { for (int i = 0; i < steps.Length; i++) { FundOutStep step = steps[i]; int stepNo = i + 1; LOG.Log(LogLevel.Debug, "TransactionId<{0}>, Step <{1}|{2}> Started With <{3}>", context.MidasTransactionId, stepNo, step.Method.Name, context); // UpdateStatus transferResult = step.Invoke(context); if (transferResult.IsSuccess()) { LOG.Log(LogLevel.Debug, "TransactionId<{0}>, Step <{1}|{2}> PassBy <{3}|{4}>", context.MidasTransactionId, stepNo, step.Method.Name, transferResult.Status.Code, transferResult.Status.Description); } else { LOG.Log(LogLevel.Debug, "TransactionId<{0}>, Step <{1}|{2}> FailIn <{3}|{4}>", context.MidasTransactionId, stepNo, step.Method.Name, transferResult.Status.Code, transferResult.Status.Description); break; } } } catch (Exception e) { LOG.Error(e, "TransactionId<{0}>, Error<{1}>", context.MidasTransactionId, e.Message); } finally { // UpdateStatus Console.WriteLine("TransferResult is [{0}|{1}]", transferResult.Status.Code, transferResult.Status.Description); } }
private void FillInterBankTransInfo(IntPtr mainFormWindow, RobotContext context) { IntPtr textToAccountName = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBStyleEdit; INSTANCE:1]"); EnterTextBox(mainFormWindow, textToAccountName, context.ToAccountName); IntPtr textToAccountNumber = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBStyleEdit; INSTANCE:2]"); EnterTextBox(mainFormWindow, textToAccountNumber, context.ToAccountNumber); IntPtr transferTypeImmediate = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBStyleRadioButton; INSTANCE:1]"); //immediate AutoItX.ControlClick(mainFormWindow, transferTypeImmediate); Thread.Sleep(GetRandomDelay(100)); IntPtr searchComboBoxToBankName = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBSearchComboBox; INSTANCE:1]"); SearchAndSelectComboBox(mainFormWindow, searchComboBoxToBankName, context.ToBankName); IntPtr textTransferAmount = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBStyleEdit; INSTANCE:4]"); EnterTextBox(mainFormWindow, textTransferAmount, context.WithdrawAmount); IntPtr textPostscript = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBStyleComboBox; INSTANCE:2]"); EnterComboBoxBox(mainFormWindow, textPostscript, context.BoTransactionId); ClickButton(mainFormWindow, 350, 660); // click 'Next' button Thread.Sleep(TimeSpan.FromSeconds(2)); }
private RobotResult DoOpenClientApp(RobotContext context) { try { int processExists = AutoItX.ProcessExists(ProcessName); if (processExists != 0) { int processClose = AutoItX.ProcessClose(ProcessName); if (processClose == AutoItXSuccess) { LOG.Log(LogLevel.Debug, "TransactionId<{0}>, Kill old process<{1}> done", context.MidasTransactionId, processExists); } } if (AutoItX.WinExists(LoginFormTitle) != AutoItXSuccess) { AutoItX.Run(ProgramFullPath, ""); int errorHappen1 = AutoItX.WinWaitActive(LoginFormTitle, "", 5); if (errorHappen1 == AutoItXSuccess) { Thread.Sleep(TimeSpan.FromSeconds(3)); } else { LOG.Error("TransactionId<{0}>, App<{1}> not found", context.MidasTransactionId, ProgramFullPath); throw new Exception("Open App Failed, Error<App Location Not Found>"); } } return(RobotResult.Build(context, RobotStatus.SUCCESS, "Open Client App Success!")); } catch (Exception e) { return(RobotResult.Build(context, RobotStatus.ERROR, e.Message)); } }
private RobotResult DoLogIn(RobotContext context) { try { IntPtr loginFormWindow = AutoItX.WinGetHandle(LoginFormTitle); IntPtr textPassBox = AutoItX.ControlGetHandle(loginFormWindow, "[CLASS:TCMBStyleEdit72]"); EnterPinBox(loginFormWindow, textPassBox, context.LoginPassword); ClickButton(loginFormWindow, 200, 400); int warningHappen1 = AutoItX.WinWaitActive("[CLASS:TPbBaseMsgForm]", "", 10); //login password validate if (warningHappen1 == AutoItXSuccess) { string errorText = AutoItX.WinGetText("[CLASS:TPbBaseMsgForm]"); RobotCMB738Utils.SaveErrorShot(context.MidasTransactionId); AutoItX.WinClose("[CLASS:TPbBaseMsgForm]"); return(RobotResult.Build(context, RobotStatus.ERROR, $"Login Failed, Error<{errorText.Trim()}>")); } RobotCMB738Utils.UntilWinActive(context.MidasTransactionId, MainWindowTitle, MainWindowText); Thread.Sleep(TimeSpan.FromSeconds(2)); // sleep wait for [CLASS:Internet Explorer_Server] load done return(RobotResult.Build(context, RobotStatus.SUCCESS, "Login Success, Awesome!")); } catch (Exception e) { return(RobotResult.Build(context, RobotStatus.ERROR, e.Message)); } }
public static void Main1(string[] args) { // 詹德宏 6214832004002676 181081 广州分行越秀支行 aa254172 452541 13168135761 Console.WriteLine("---------------------------1234---------------------------"); string[] bankNames = { "交通银行", "招商银行", "中国工商银行" }; string[] acctNames = { "阿拉木斯", "吕文斌", "李忠谦" }; string[] acctNums = { "6222620910034272595", "6214837694277025", "6212262102018676967" }; int loopTimes = 1; for (int i = 0; i < loopTimes; i++) { RobotContext context = new RobotContext(); context.MidasTransactionId = "100100" + i; context.LoginPassword = "******"; context.ToBankName = bankNames[i]; context.ToAccountName = acctNames[i]; context.ToAccountNumber = acctNums[i]; context.WithdrawAmount = "1.00"; context.BoTransactionId = "123-4567-890" + i; RobotCMB738 robot = new RobotCMB738(); robot.Transfer(context); Thread.Sleep(TimeSpan.FromSeconds(3)); } Console.WriteLine("---------------------------5678---------------------------"); Console.ReadKey(); }
public static RobotResult Default(RobotContext context) { return(new RobotResult { Context = context, Status = RobotStatus.Default() }); }
private void FillWithdrawPin(IntPtr mainFormWindow, RobotContext context) { IntPtr textPinBox = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBEdit; INSTANCE:1]"); EnterWithdrawPinBox(mainFormWindow, textPinBox, context.TokenWithdrawPin); ClickButton(mainFormWindow, textPinBox, 70, 50); // click 'Next' button Thread.Sleep(GetRandomDelay(1000)); }
public static RobotResult Build(RobotContext context, int code, string desc) { return(new RobotResult { Context = context, Status = new RobotStatus(code, desc) }); }
private RobotResult DoGetBalance(RobotContext context) { try { IntPtr mainFormWindow = GetMainFormWindow(); AutoItX.WinActivate(mainFormWindow); ClickButton(mainFormWindow, 50, 80); // click HomePage button Thread.Sleep(TimeSpan.FromSeconds(3)); // sleep wait for [CLASS:Internet Explorer_Server] load done ClickButton(mainFormWindow, 230, 480); // click Statement button Thread.Sleep(TimeSpan.FromSeconds(5)); // sleep wait for [CLASS:Internet Explorer_Server] load done ClickButton(mainFormWindow, 1580, 390); // click Download button WaitUtils.UntilWinActive("[TITLE:File Download; CLASS:#32770]", ""); AutoItX.WinActivate("[TITLE:File Download; CLASS:#32770]", ""); Thread.Sleep(TimeSpan.FromSeconds(1)); AutoItX.ControlClick("[TITLE:File Download; CLASS:#32770]", "", "[CLASS:Button; INSTANCE:2]"); // click Save button WaitUtils.UntilWinActive("[TITLE:Save As; CLASS:#32770]", ""); ChangeDownloadPath($@"{StatementBaseFolder}\{context.FromAccountNumber}"); Thread.Sleep(TimeSpan.FromSeconds(1)); AutoItX.ControlClick("[TITLE:Save As; CLASS:#32770]", "", "[CLASS:Button; INSTANCE:2]"); // click Save button int warningHappen1 = AutoItX.WinWaitActive("[TITLE:Confirm Save As; CLASS:#32770]", "", 2); if (warningHappen1 == AutoItXSuccess) { AutoItX.WinActivate("[TITLE:Confirm Save As; CLASS:#32770]", ""); Thread.Sleep(TimeSpan.FromSeconds(1)); AutoItX.ControlClick("[TITLE:Confirm Save As; CLASS:#32770]", "", "[CLASS:Button; INSTANCE:1]"); // click Yes button } WaitUtils.UntilWinActive("[TITLE:Download complete; CLASS:#32770]", ""); AutoItX.WinActivate("[TITLE:Download complete; CLASS:#32770]", ""); Thread.Sleep(TimeSpan.FromSeconds(1)); AutoItX.ControlClick("[TITLE:Download complete; CLASS:#32770]", "", "[CLASS:Button; INSTANCE:4]"); // click Close button Thread.Sleep(TimeSpan.FromSeconds(2)); return(RobotResult.Build(context, RobotStatus.SUCCESS, "")); } catch (Exception e) { return(RobotResult.Build(context, RobotStatus.ERROR, e.Message)); } }
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 RobotResult DoTransfer(RobotContext context) { try { IntPtr mainFormWindow = GetMainFormWindow(); AutoItX.WinActivate(mainFormWindow); ClickButton(mainFormWindow, 50, 80); // click HomePage button Thread.Sleep(TimeSpan.FromSeconds(3)); // sleep wait for [CLASS:Internet Explorer_Server] load done ClickButton(mainFormWindow, 60, 320); // click Transfer button, default 'Same-bank transfer' WaitUtils.UntilControlFocus(MainWindowTitle, MainWindowText, "[CLASS:TCMBSearchComboBox; INSTANCE:1]"); if (string.IsNullOrEmpty(context.ToBankName)) { FillSameBankTransInfo(mainFormWindow, context); } else { ClickButton(mainFormWindow, 250, 210); // click 'Inter-bank transfer' button WaitUtils.UntilControlFocus(MainWindowTitle, MainWindowText, "[CLASS:TCMBStyleRadioButton; INSTANCE:1]"); FillInterBankTransInfo(mainFormWindow, context); } WaitUtils.UntilControlFocus(MainWindowTitle, MainWindowText, "[CLASS:TCMBEdit; INSTANCE:1]"); FillWithdrawPin(mainFormWindow, context); int errorHappen1 = AutoItX.WinWaitActive("[TITLE:错误; CLASS:TErrorWithHelpForm]", "", 5); //transfer pre-check failed if (errorHappen1 == AutoItXSuccess) { AutoItX.WinClose("[TITLE:错误;CLASS:TErrorWithHelpForm]"); return(RobotResult.Build(context, RobotStatus.ERROR, "Transfer Failed1, Error<Withdraw Validate Failed>")); } WaitUtils.UntilWinActive("[CLASS:TTransferSuccessFrm]", context.ToAccountName); AutoItX.WinClose("[CLASS:TTransferSuccessFrm]"); return(RobotResult.Build(context, RobotStatus.SUCCESS, "")); } catch (Exception e) { return(RobotResult.Build(context, RobotStatus.ERROR, e.Message)); } }
private RobotResult DoTransfer(RobotContext context) { try { IntPtr mainFormWindow = GetMainFormWindow(); AutoItX.WinActivate(mainFormWindow); ClickButton(mainFormWindow, 60, 320); // click 'Transfer' button RobotCMB738Utils.UntilControlFocus(context.MidasTransactionId, MainWindowTitle, MainWindowText, "[CLASS:TCMBStyleEdit72; INSTANCE:4]"); FillBankTransInfo(mainFormWindow, context); ClickButton(mainFormWindow, 180, 650); // click 'Next' button RobotCMB738Utils.UntilControlFocus(context.MidasTransactionId, MainWindowTitle, MainWindowText, "[CLASS:TCMBStyleEdit72; INSTANCE:4000]"); return(RobotResult.Build(context, RobotStatus.SUCCESS, "")); } catch (Exception e) { return(RobotResult.Build(context, RobotStatus.ERROR, e.Message)); } }
private void FillBankTransInfo(IntPtr mainFormWindow, RobotContext context) { IntPtr textToAccountName = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:Edit; INSTANCE:1]"); EnterTextBox(mainFormWindow, textToAccountName, context.ToAccountName); IntPtr textToAccountNumber = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBStyleEdit72; INSTANCE:5]"); EnterTextBox(mainFormWindow, textToAccountNumber, context.ToAccountNumber); IntPtr searchComboBoxToAccountBank = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBSearchComboBox72; INSTANCE:5]"); AutoItX.ControlClick(mainFormWindow, searchComboBoxToAccountBank); Thread.Sleep(TimeSpan.FromSeconds(1)); IntPtr textTransferAmount = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBStyleEdit72; INSTANCE:4]"); EnterTextBox(mainFormWindow, textTransferAmount, context.WithdrawAmount); IntPtr textPostscript = AutoItX.ControlGetHandle(mainFormWindow, "[CLASS:TCMBStyleComboBox72; INSTANCE:2]"); EnterPinBox(mainFormWindow, textPostscript, context.BoTransactionId); }
public static void Main1(string[] args) { Console.WriteLine("---------------------------1234---------------------------"); RobotContext context = new RobotContext(); //context.FromAccountName = "詹德宏"; //context.FromAccountNumber = "6214832004002670"; //context.LoginPassword = "******"; //context.TokenWithdrawPin = "452541"; context.FromAccountName = "庄洲荣"; context.FromAccountNumber = "6214835924582826"; context.LoginPassword = "******"; context.TokenWithdrawPin = "360382"; string[] bankNames = { "", "交通银行", "" }; string[] acctNames = { "吕文斌", "阿拉木斯", "" }; string[] acctNums = { "6214837694277025", "6222620910034272595", "" }; int loopTimes = 1; for (int i = 0; i < loopTimes; i++) { context.MidasTransactionId = "100100" + i; context.ToBankName = bankNames[i]; context.ToAccountCity = "苏州"; context.ToAccountName = acctNames[i]; context.ToAccountNumber = acctNums[i]; context.WithdrawAmount = "1.00"; context.BoTransactionId = "123-4567-891" + i; RobotCMB robot = new RobotCMB(); robot.Transfer(context); Thread.Sleep(TimeSpan.FromSeconds(10)); } Console.WriteLine("---------------------------5678---------------------------"); Console.ReadKey(); }
private RobotResult DoLogOut(RobotContext context) { try { IntPtr mainFormWindow = GetMainFormWindow(); AutoItX.WinActivate(mainFormWindow); Rectangle mainWindowPosition = AutoItX.WinGetPos(mainFormWindow); ClickButton(mainFormWindow, mainWindowPosition.Width - 150, 10); int warningHappen1 = AutoItX.WinWaitActive("[CLASS:TAppExitForm]", "", 5); if (warningHappen1 == AutoItXSuccess) { IntPtr warningPopWin1 = AutoItX.WinGetHandle("[CLASS:TAppExitForm]"); ClickButton(warningPopWin1, 110, 190); } int warningHappen2 = AutoItX.WinWaitActive("[CLASS:TPbBaseMsgForm]", "移动证书优KEY还插在电脑", 5); if (warningHappen2 == AutoItXSuccess) { IntPtr warningPopWin2 = AutoItX.WinGetHandle("[CLASS:TPbBaseMsgForm]", "移动证书优KEY还插在电脑"); ClickButton(warningPopWin2, 250, 170); } int warningHappen3 = AutoItX.WinWaitActive("[CLASS:TPbBaseMsgForm]", "再次确认是否要不拔掉优KEY退出专业版", 5); if (warningHappen3 == AutoItXSuccess) { IntPtr warningPopWin3 = AutoItX.WinGetHandle("[CLASS:TPbBaseMsgForm]", "再次确认是否要不拔掉优KEY退出专业版"); ClickButton(warningPopWin3, 260, 160); } Thread.Sleep(TimeSpan.FromSeconds(2)); return(RobotResult.Build(context, RobotStatus.SUCCESS, "")); } catch (Exception e) { return(RobotResult.Build(context, RobotStatus.ERROR, e.Message)); } }