public void StartThis(string appName, string appPath) { var aUI3 = new UIA3Automation(); Process apps = Process.Start(appPath); System.Threading.Thread.Sleep(30000); Process[] SC = Process.GetProcesses(); foreach (Process proc in SC) { System.Diagnostics.Debug.Write(" proc :: " + proc.ProcessName.ToLower() + " " + appName.ToLower() + "\n"); if (proc.ProcessName.ToLower().Contains(appName.ToLower())) { appProcess = proc; break; } } app = FlaUI.Core.Application.Attach(appProcess); appWindow = app.GetMainWindow(aUI3, TimeSpan.FromMilliseconds(5000)); System.Diagnostics.Debug.Write(" WIDTH " + appWindow.Properties.BoundingRectangle.Value.Width); this.WIDTH = appWindow.Properties.BoundingRectangle.Value.Width; this.HEIGHT = appWindow.Properties.BoundingRectangle.Value.Height; }
private async void ProcessLimit_Click(object sender, RoutedEventArgs e) { var Processname = ModelItem.GetValue <string>("Processname"); var p = System.Diagnostics.Process.GetProcessesByName(Processname).FirstOrDefault(); if (p == null) { return; } FlaUI.Core.AutomationElements.Window window = null; using (var app = Interfaces.AutomationUtil.getAutomation()) { var _app = FlaUI.Core.Application.Attach(p.Id); window = _app.GetAllTopLevelWindows(app).FirstOrDefault(); } if (window == null) { return; } Interfaces.GenericTools.minimize(Interfaces.GenericTools.mainWindow); var rect = await getrectangle.GetitAsync(); if (window.BoundingRectangle.Contains(rect)) { var limit = new System.Drawing.Rectangle(rect.X - (int)window.BoundingRectangle.X, rect.Y - (int)window.BoundingRectangle.Y, rect.Width, rect.Height); ModelItem.Properties["Limit"].SetValue(new System.Activities.InArgument <System.Drawing.Rectangle>(limit)); } Interfaces.GenericTools.restore(); NotifyPropertyChanged("Limit"); }