private AutomationElement FindTargetApplicationRoot(int targetProcessId)
        {
            var element = Automation.GetDesktop();
            var root    = element.FindFirstChild(c => c.ByProcessId(targetProcessId));

            return(root);
        }
Exemple #2
0
        /// <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);
        }
Exemple #3
0
        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());
        }
Exemple #4
0
 public CodeProvider(CodeProviderArguments args) : base(args)
 {
     _existingVariables.Add("window", GetMainWindow());
     _existingVariables.Add("desktop", Automation.GetDesktop());
 }