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

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