static void Main(string[] args) { //pega a posição do mause int x = AutoItX.MouseGetPos().X; int y = AutoItX.MouseGetPos().Y; Console.WriteLine("x"); Console.WriteLine(x.ToString()); Console.WriteLine("y"); Console.WriteLine(y.ToString()); //move o mause AutoItX.MouseMove(540, 752, 3); AutoItX.MouseClick("LEFT", 540, 752, 1); AutoItX.ProcessWait(null, 10); //AutoItX.Sleep(30000); //clica no brauser AutoItX.MouseMove(843, 56, 3); AutoItX.MouseClick("LEFT", 843, 56, 1); Console.WriteLine("esperando"); //da uma pausa AutoItX.ProcessWait(null, 3); Console.WriteLine("feito"); AutoItX.MouseMove(689, 61, 3); AutoItX.MouseClick("LEFT", 689, 61, 1); AutoItX.Send("http://www.realsis.com.br/teste"); AutoItX.ProcessWait(null, 3); AutoItX.Send("{BACKSPACE}"); AutoItX.Send("{BACKSPACE}"); AutoItX.Send("{BACKSPACE}"); AutoItX.Send("{BACKSPACE}"); AutoItX.Send("{BACKSPACE}"); AutoItX.Send("{BACKSPACE}"); AutoItX.ProcessWait(null, 3); AutoItX.Send("{ENTER}"); AutoItX.ProcessWait(null, 7); //click do mouse AutoItX.MouseClick("LEFT", 689, 61, 1); //copiar AutoItX.Send("^c"); AutoItX.ProcessWait(null, 3); //botão do windows AutoItX.Send("{LWIN}"); AutoItX.ProcessWait(null, 2); AutoItX.Send("bloco"); AutoItX.ProcessWait(null, 2); AutoItX.Send("{ENTER}"); AutoItX.ProcessWait(null, 3); //colar AutoItX.Send("^v"); }
/// <summary> /// Закрытие процесса /// </summary> /// <param name="nameproces">Наименование процеса пример "AcroRd32.exe", /// "FoxitPhantom.exe" /// </param> /// <param name="timer">Время ожидания процесса</param> public static void Process(string nameproces, int timer) { AutoItX.ProcessWait(nameproces, timer); AutoItX.Sleep(2000); //Можно контролить процесс while (true) { if (AutoItX.ProcessExists(nameproces) > 0) { AutoItX.ProcessClose(nameproces); } if (AutoItX.ProcessExists(nameproces) == 0) { break; } } }
/// <summary> /// Дожидаемся и сохраняем XLSX 2010 и закрываем /// </summary> public static void ExcelSaveAndClose() { AutoItX.ProcessWait("EXCEL.EXE", 60000); var processExcel = FindIntPtr("[CLASS:XLMAIN]"); LibraryAutomations libraryAutomationXlsx = new LibraryAutomations(processExcel); try { var save = "ClassName:MsoCommandBar\\ClassName:MsoWorkPane\\ClassName:NUIPane\\ClassName:NetUIHWNDElement\\ClassName:NetUInetpane\\ClassName:NetUIElement\\Name:Сохранить"; var closeLicense = "ClassName:NetUIHWNDElement\\ClassName:NetUINetUIDialog\\Name:Закрыть"; while (true) { var allClass = libraryAutomationXlsx.SelectAutomationColrction(libraryAutomationXlsx.RootAutomationElements); if (libraryAutomationXlsx.IsEnableElements(save, allClass[1]) != null) { AutoItX.Send("^s"); AutoItX.Sleep(2000); break; } if (libraryAutomationXlsx.IsEnableElements(closeLicense, allClass[0]) != null) { libraryAutomationXlsx.InvokePattern(libraryAutomationXlsx.FindElement); } } } catch (Exception) { // ignored } finally { AutoItX.Send("^s"); libraryAutomationXlsx.Dispose(); CloseProcessProgram("EXCEL"); } }
/// <summary> /// Обработка ветки Налоговое администрирование\Контрольная работа (налоговые проверки)\101. Мониторинг и обработка документов\Реестр документов НБО /// </summary> /// <param name="libraryAutomation">Библиотека автоматизации</param> /// <param name="regNumDeclaration">Регистрационный номер декларации</param> /// <param name="pathTemp">Путь к сохранению документа</param> private decimal?DeclarationIntelligenceUl(LibraryAutomations libraryAutomation, int regNumDeclaration, string pathTemp) { if (!libraryAutomation.IsEnableExpandTree(Tree)) { return(null); } var sw = Tree.Split('\\').Last(); var fullTree = string.Concat(PublicElementName.FullTree, $"Name:{sw}"); DataBaseElementAdd dataBaseAdd = new DataBaseElementAdd(); WindowsAis3 win; libraryAutomation.FindFirstElement(fullTree, null, true); libraryAutomation.FindElement.SetFocus(); libraryAutomation.ClickElements(fullTree, null, false, 25, 0, 0, 2); while (true) { if (libraryAutomation.FindFirstElement(string.Concat(TreeDataArea, 9), null, true) != null) { libraryAutomation.FindFirstElement("Name:Значение", libraryAutomation.FindElement, true); libraryAutomation.FindElement.SetFocus(); SendKeys.SendWait("{ENTER}"); AutoItX.Sleep(500); SendKeys.SendWait(regNumDeclaration.ToString()); break; } } PublicGlobalFunction.PublicGlobalFunction.WindowElementClick(libraryAutomation, TreeUpdate); PublicGlobalFunction.PublicGlobalFunction.GridNotDataIsWaitUpdate(libraryAutomation, FullPathGrid); if (PublicGlobalFunction.PublicGlobalFunction.GridNotDataIsWaitUpdate(libraryAutomation, FullPathGrid) != "Данные, удовлетворяющие заданным условиям не найдены.") { var allReport = libraryAutomation .SelectAutomationColrction(libraryAutomation.IsEnableElements(FullPathGrid)) .Cast <AutomationElement>().Where(elem => elem.Current.Name != "Data Area").Distinct().ToList(); foreach (var element in allReport) { var declarationAll = dataBaseAdd.AddDeclarationAll(libraryAutomation, element); while (true) { PublicGlobalFunction.PublicGlobalFunction.WindowElementClick(libraryAutomation, PreCheckElementNameDeclaration.ReestrNbo); PublicGlobalFunction.PublicGlobalFunction.WindowElementClick(libraryAutomation, PreCheckElementNameDeclaration.ViewDeclaretion); AutoItX.Sleep(10000); if (libraryAutomation.IsEnableElements(TreeExport) != null) { PublicGlobalFunction.PublicGlobalFunction.WindowElementClick(libraryAutomation, TreeExport); break; } } PublicGlobalFunction.PublicGlobalFunction.WindowElementClick(libraryAutomation, PreCheckElementNameDeclaration.ExportFileOk); AutoItX.ProcessWait("EXCEL.EXE", 60000); AutoItX.Sleep(Convert.ToInt32(ConfigurationManager.AppSettings["Sleepeng"])); PublicGlobalFunction.PublicGlobalFunction.CloseProcessProgram("EXCEL"); var file = PublicGlobalFunction.PublicGlobalFunction.ReturnNameLastFileTemp(pathTemp, "*.xlsx"); dataBaseAdd.AddDeclarationDataAll(file.NamePath, declarationAll); win = new WindowsAis3(); AutoItX.MouseClick(ButtonConstant.MouseLeft, win.WindowsAis.X + win.WindowsAis.Width - 20, win.WindowsAis.Y + 160); } } win = new WindowsAis3(); AutoItX.MouseClick(ButtonConstant.MouseLeft, win.WindowsAis.X + win.WindowsAis.Width - 20, win.WindowsAis.Y + 160); return(dataBaseAdd.DeclarationSumError(regNumDeclaration)); //Расчет и возврат суммы }
public int ProcessWait(string process, int timeout) { return(AutoItX.ProcessWait(process, timeout)); }