private AutomationElement FindTargetApplicationRoot(int targetProcessId) { var element = Automation.GetDesktop(); var root = element.FindFirstChild(c => c.ByProcessId(targetProcessId)); return(root); }
/// <summary> /// Gets the main window (first window on desktop with the same process as this window). /// </summary> private Window GetMainWindow() { if (IsMainWindow) { return(this); } var mainWindow = Automation.GetDesktop().FindFirstChild(cf => cf.ByProcessId(Properties.ProcessId.Value)).AsWindow(); return(mainWindow ?? this); }
public CodeProvider(CodeProviderArguments args) : base(args) { var executable = args?.TargetProcess?.MainModule.FileName; _builder.AppendLine(AddPowerShellHeader(executable)); _existingVariables.Add("window", GetMainWindow()); _existingVariables.Add("desktop", Automation.GetDesktop()); }
public CodeProvider(CodeProviderArguments args) : base(args) { _existingVariables.Add("window", GetMainWindow()); _existingVariables.Add("desktop", Automation.GetDesktop()); }