Created
September 6, 2018 09:54
-
-
Save vildar82/d7f314a33356d25a4d326781b9d1a39b to your computer and use it in GitHub Desktop.
Civil automate insert shortcut by FlaUI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal static void Automate(UIJob uiJob) | |
{ | |
Console.WriteLine("Нажми любую кнопку для старта:"); | |
Console.ReadKey(); | |
App = Application.Attach(uiJob.ProcessID); | |
using (Auto = new UIA3Automation()) | |
{ | |
var mainWin = App.GetMainWindow(Auto); | |
Console.WriteLine($"Главное окно - {mainWin.Name}"); | |
var elem = mainWin.FindFirstByXPath("/Pane[@Name='Область инструментов']/Pane[@Name='Навигатор']"); | |
Console.WriteLine($"{elem.Name}"); | |
var gl = elem.FindFirst(TreeScope.Children, elem.ConditionFactory.ByName("Навигатор:Главное представление")); | |
Console.WriteLine($"{gl.Name}"); | |
var pane = gl.FindFirstByXPath("/Pane/Pane"); | |
var tree = pane.FindFirstChild(gl.ConditionFactory.ByControlType(ControlType.Tree)).AsTree(); | |
var tiShorts = tree.Items.FirstOrDefault(i => i.Name.StartsWith("Быстрые ссылки")); | |
Console.WriteLine($"{tiShorts.Name}"); | |
tiShorts.Expand(); | |
var tiNets = tiShorts.Items.FirstOrDefault(i => i.Name.StartsWith("Трубопроводные сети")); | |
Console.WriteLine($"{tiNets.Name}"); | |
tiNets.Expand(); | |
foreach (var item in tiNets.Items) | |
{ | |
Console.WriteLine($"Вставка быстрой ссылки {item.Name}"); | |
item.Select(); | |
item.RightClick(); | |
Mouse.MoveBy(50, 5); | |
Mouse.Click(MouseButton.Left); | |
while (true) | |
{ | |
var winLink = mainWin.ModalWindows.FirstOrDefault(w => w.Name == "Создать ссылку трубопроводной сети"); | |
if (winLink == null) | |
{ | |
Thread.Sleep(100); | |
continue; | |
} | |
var bOk = winLink.FindFirstByXPath("/Button[@Name='OK']").AsButton(); | |
bOk.Click(); | |
App.WaitWhileBusy(); | |
Thread.Sleep(3000); | |
break; | |
} | |
} | |
Console.ReadKey(); | |
//uiJob.Container.Automate(mainWin); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment