示例#1
0
 private void UnsetAsCurrent()
 {
     if (CurrentForeground == this)
     {
         CurrentForeground = null;
     }
 }
示例#2
0
        public static ControlledWindow Capture(string processName, Action action, bool maximize = true)
        {
            var prevProcesses = Process.GetProcessesByName(processName);
            var prevTitleMap  = GetProcessTitleMap(prevProcesses);

            action();
            var processes = Process.GetProcessesByName(processName);
            var titleMap  = GetProcessTitleMap(processes);
            var diff      = DiffMap(prevTitleMap, titleMap).ToArray();

            if (diff.Length == 1)
            {
                var proc = Process.GetProcessById(diff[0]);
                var w    = new ControlledWindow
                {
                    Process           = proc,
                    ProcessPath       = proc.StartInfo.FileName,
                    Arguments         = proc.StartInfo.Arguments,
                    MaximizeOnStartup = maximize,
                    Status            = Statuses.WindowValid
                };
                w.SwitchToThisWindow();
                return(w);
            }
            return(null);
        }
示例#3
0
 private void SetAsCurrent()
 {
     CurrentForeground = this;
 }