private void Wait(string appTitle, string panelId, string selectionMessage) { bool isStarted = false; while (!isStarted) { Thread.Sleep(1000); var processes = Process.GetProcesses(); foreach (var prServiceInstallExist in processes) { if (prServiceInstallExist.MainWindowTitle == appTitle) ///*|| prServiceInstallExist.MainWindowTitle == "Continuous Monitoring Insight Setup" { _robot.ControlFocus(appTitle, "", panelId); if (_robot.ControlGetText(appTitle, "", panelId) == selectionMessage || _robot.ControlGetText(appTitle, "", panelId).Contains(selectionMessage)) { isStarted = true; Thread.Sleep(1000); break; } } } } }
private Boolean waitText(String title, String control, String[] arrSText, String fText, int maxWait) { String textTmp = ""; int countWait = 0; while (true) { countWait++; if (countWait > maxWait) { return(false); } textTmp = au3.ControlGetText(title, "", control); foreach (String sText in arrSText) { if (textTmp.Contains(sText)) { return(true); } } if (textTmp.Contains(fText)) { return(false); } System.Threading.Thread.Sleep(1000); } }
public bool ButtonClick(string appTitle, string text, string panelId, string btnControl, string selectionMessage) { try { _robot.WinActivate(appTitle); if (_robot.ControlGetText(appTitle, text, panelId) == selectionMessage || _robot.ControlGetText(appTitle, text, panelId).Contains(selectionMessage)) { _robot.ControlFocus(appTitle, text, btnControl); _robot.Send("{ENTER}"); Sleep(500); } return(true); } catch (Exception) { return(false); } }
// Блок private void timer2_Tick(object sender, EventArgs e) { AutoItX3 autoIt = new AutoItX3(); if (autoIt.WinExists("ОШИБКА") == 1) { string t = autoIt.ControlGetText("ОШИБКА", "", "TStaticText1"); string pos = "ПЕРЕПОЛНЕНИЕ"; if (t.Contains(pos)) { autoIt.WinActivate("ОШИБКА"); autoIt.WinGetState("ОШИБКА"); autoIt.ControlClick("ОШИБКА", "", "[CLASS:TBitBtn; INSTANCE:1]", "main", 1); autoIt.Sleep(5000); autoIt.WinClose(textBox2.Text); autoIt.Sleep(4000); autoIt.WinActivate("ЗАВЕРШЕНИЕ РАБОТЫ"); autoIt.WinGetState("ЗАВЕРШЕНИЕ РАБОТЫ"); autoIt.Sleep(2000); autoIt.ControlClick("ЗАВЕРШЕНИЕ РАБОТЫ", "", "[CLASS:Button; INSTANCE:1]", "main", 1); autoIt.Sleep(Convert.ToInt16(textBox5.Text)); autoIt.Run(textBox1.Text); autoIt.Sleep(7000); autoIt.WinActivate("ВЫБОР БИБЛИОТЕК"); autoIt.WinGetState("ВЫБОР БИБЛИОТЕК"); autoIt.Sleep(3000); //Выбор библиотеки поцвету пикселя начало object coord = autoIt.PixelSearch(0, 0, Screen.GetWorkingArea(this).Width, Screen.GetWorkingArea(this).Height, Convert.ToInt32(Convert.ToString(textBox3.Text), 16));//edit texbox3 hex object[] pixelcoord = (object[])coord; autoIt.MouseClick("Left", (int)pixelcoord[0], (int)pixelcoord[1], 1, 10); //Выбор библиотеки поцвету пикселя конец autoIt.Sleep(Convert.ToInt16(textBox6.Text)); //Запуск PostWin поцвету пикселя начало autoIt.WinActivate(textBox2.Text); autoIt.WinGetState(textBox2.Text); autoIt.Sleep(2000); object coord1 = autoIt.PixelSearch(0, 0, Screen.GetWorkingArea(this).Width, Screen.GetWorkingArea(this).Height, Convert.ToInt32(Convert.ToString(textBox4.Text), 16));//edit textbox4 hex object[] pixelcoord1 = (object[])coord1; autoIt.MouseClick("Left", (int)pixelcoord1[0], (int)pixelcoord1[1], 1, 10); //Запуск PostWin поцвету пикселя конец autoIt.Sleep(2000); //*** Запись лога string date = DateTime.Now.ToString("dd MMMM yyyy,HH:mm:ss"); System.IO.StreamWriter writer = new System.IO.StreamWriter("slib.dll", true); writer.WriteLine(date); writer.Close(); //*** Запись лога конец } else { timer2.Interval = 1; // Выбираем из массива случайное значение для таймера } } }
public string GetCustomerNumber() { string Division = _Au3Lib.WinGetTitle("Order Log"); switch (Division) { case "Order Log - Kirby (Test)": return("7825"); case "Order Log - GSM (Test)": return("00771"); case "Order Log - CBC (Test)": return("030117"); case "Order Log - Waterloo": return("FAC100"); case "Order Log - Utah": string DivisionLetter = _Au3Lib.ControlGetText("New Order Number", "", "[NAME:lblDivision]"); if (DivisionLetter == "U") { return("FIS200"); } else { return("694998"); } case "Order Log - Swansea": return("STEELMASTER"); case "Order Log - Terrell": return("MET120"); case "Order Log - IT DEVELOPMENT SOUTH": return("555999"); case "Order Log - IT DEVELOPMENT ATL": return("0000692"); case "Order Log - IT DEVELOPMENT MW": return("794999"); case "Order Log - IT DEVELOPMENT WEST": return("007160"); default: MessageBox.Show("The customer number is determined from the title of the Order Log. Either the Order Log is not open, the title has been changed, or you are not in a Testing environment."); return(null); } }
public void BookJob(int numberOfPhases) { _Au3Lib.Opt("WinTitleMatchMode", 2); //determines if Order Log is open. Terminates program if it isn't. string windowTitle = "Order Entry"; _Au3.CheckIfWindowExists(windowTitle); string currentJobName = _Au3Lib.ControlGetText(windowTitle, "", "[NAME:txtOrderName]"); _Au3.InputProjectInfo(windowTitle, currentJobName, numberOfPhases); _Au3Lib.ControlFocus(windowTitle, "", "[NAME:cboPriceType]"); string division = _Au3.GetDivision(); _Au3.GetPriceType(division); _Au3.SetEndUseCode(windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:btnSaveProject]", "left", 1); _Au3.DetermineControlVisibility("[NAME:PictureBoxHappy]", windowTitle); //Phasings/Buildings Screen (for Prebook) _Au3Lib.ControlClick(windowTitle, "", "[NAME:ProjectFeaturesTab]", "left", 1, 116, 12); _Au3.DetermineControlVisibility("[NAME:btnSaveBldgInfo]", windowTitle); _Au3Lib.WinActivate(windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:FpSpread_Bldg]", "left", 1, 293, 52); //Adds 1,000 to each subsequent category, choosing the first value based on division (hard-coded at the moment) _Au3.InputBuildingInfoWeightDollars(division); _Au3Lib.ControlClick(windowTitle, "", "[NAME:btnSaveBldgInfo]"); _Au3.DetermineControlVisibility("[NAME:picboxHappy_BldgInfo]", windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:btnPrebookFromBldg]"); _Au3.DetermineControlVisibility("[NAME:btnSaveMultiPhasesToDB]", windowTitle); _Au3.DisableEmail(windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:btnSaveMultiPhasesToDB]"); _Au3Lib.Sleep(1000); //transfer $$ and ## to Phases _Au3Lib.ControlClick(windowTitle, "", "[NAME:ProjectFeaturesTab]", "left", 116, 12); _Au3.DetermineControlVisibility("[NAME:btnSaveBldgInfo]", windowTitle); _Au3Lib.WinActivate(windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:FpPhaseTool]", "left", 1, 34, 27); if (numberOfPhases == 1) { _Au3Lib.Send("A{TAB}1{TAB}100{ENTER}"); _Au3Lib.Sleep(250); } else if (numberOfPhases == 2) { _Au3Lib.Send("A{TAB}1{TAB}70{ENTER}"); _Au3Lib.Sleep(250); _Au3Lib.Send("{DOWN}30+{TAB}1+{TAB}B{ENTER}"); _Au3Lib.Sleep(250); } _Au3Lib.ControlClick(windowTitle, "", "[NAME:btnSaveBldgInfo]"); _Au3.DetermineControlVisibility("[NAME:picboxHappy_BldgInfo]", windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:btnTsfrToPhases]"); _Au3.DetermineControlVisibility("[NAME:btnSaveMultiPhasesToDB]", windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:btnSaveMultiPhasesToDB]"); //Project Dates Screen _Au3.DetermineControlVisibility("[NAME:btnSaveProjectDates2]", windowTitle); string[] arraycoordinates = _Au3.GetCoordinatesForProjectDates(division).Split(','); int[] coordinates = new int[arraycoordinates.Length]; //for (int i = 0; i < arraycoordinates.Length; i++) //{ // coordinates[i] = Integer.parseInt(arraycoordinates[i]); //} //$Coords = StringSplit(Call("GetCoords",$Division), ",") _Au3Lib.ControlClick(windowTitle, "", "[NAME:FpSpreadProjDates]", "LEFT", 1, 304, 366); DateTime currentDate = DateTime.Now; //string format = "m/d/yy"; string formattedDate = currentDate.ToShortDateString(); _Au3Lib.Send(formattedDate); _Au3Lib.Send("{ENTER}"); _Au3Lib.ControlClick(windowTitle, "", "[NAME:btnSaveProjectDates2]"); _Au3.DetermineControlVisibility("[NAME:picboxHappy_Dates]", windowTitle); //Making phases Active _Au3Lib.ControlClick(windowTitle, "", "[NAME:ProjectFeaturesTab]", "", 1, 118, 9); _Au3.DetermineControlVisibility("[NAME:btnSaveBldgInfo]", windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:TabControl4]", "", 1, 171, 12); _Au3.DetermineControlVisibility("[NAME:chkBookTonsDoll_ViewTons]", windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:lvwSalesSummary]", "right", 1, 180, 70); _Au3Lib.Sleep(250); _Au3Lib.Send("{DOWN 4}"); _Au3Lib.Send("{ENTER}"); _Au3Lib.Sleep(3000); if (_RunSettings.NumberOfPhases == 2) { _Au3Lib.ControlClick(windowTitle, "", "[NAME:lvwSalesSummary]", "right", 1, 180, 138); _Au3Lib.Sleep(250); _Au3Lib.Send("{DOWN 4}"); _Au3Lib.Send("{ENTER}"); } }