コード例 #1
0
        private void guessAll_Click(object sender, EventArgs e)
        {
            if (loglevel.SelectedIndex == 0)
            {
                loglevel.SelectedIndex = -1;
            }
            log.Text = "";
            Process[] all = Process.GetProcesses();
            int       idx = 0;

            foreach (Process p in all)
            {
                IntPtr hWnd = p.MainWindowHandle;
                bool   mainModuleOk;
                try
                {
                    p.MainModule.FileName.ToString();
                    mainModuleOk = true;
                }
                catch
                {
                    mainModuleOk = false;
                    log.Text    += p.ProcessName + ":\t(Access denied)\r\n";
                }
                if (mainModuleOk && hWnd == IntPtr.Zero)
                {
                    SystemWindow[] swl = SystemWindow.FilterToplevelWindows(delegate(SystemWindow sw)
                    {
                        return(sw.Process.Id == p.Id);
                    });
                    if (swl.Length > 0)
                    {
                        hWnd = swl[0].HWnd;
                    }
                }

                if (mainModuleOk && hWnd != IntPtr.Zero)
                {
                    SystemWindow sw = new SystemWindow(hWnd);
                    if (loglevel.SelectedIndex != -1)
                    {
                        log.Text += "===" + sw.Title + " (" + p.ProcessName + ") ===\r\n";
                    }
                    attributes.Clear();
                    controller.guessWindow(this, sw);
                    string summary = controller.summarize(this, attributes.ToArray());
                    if (loglevel.SelectedIndex == -1)
                    {
                        log.Text += p.ProcessName + ":\t" + summary + "\r\n";
                    }
                }
                Text = "GuessEXE - " + (++idx) + "/" + all.Length;
                Validate();
            }
            if (loglevel.SelectedIndex == -1)
            {
                loglevel.SelectedIndex = 0;
            }
            Text = "GuessEXE";
        }
コード例 #2
0
        public static SystemWindow GetMainSystemWindow()
        {
            var mainSystemWindow = SystemWindow.FilterToplevelWindows(delegate(SystemWindow systemWindow)
            {
                return(systemWindow.ClassName == "Progman" &&
                       systemWindow.Title == "Program Manager" &&
                       systemWindow.Process.ProcessName == "explorer");
            });

            if (mainSystemWindow.Length != 1)
            {
                Log.WriteLine("Unable to find the desktop.");

                return(null);
            }

            mainSystemWindow = mainSystemWindow[0].FilterDescendantWindows(false, delegate(SystemWindow systemWindow)
            {
                return(systemWindow.ClassName == "SysListView32" && systemWindow.Title == "FolderView");
            });

            if (mainSystemWindow.Length != 1)
            {
                Log.WriteLine("Unable to find the desktop.");

                return(null);
            }

            return(mainSystemWindow[0]);
        }
コード例 #3
0
        private SystemListView GetDesktopListView()
        {
            SystemWindow[] sws = SystemWindow.FilterToplevelWindows(delegate(SystemWindow sw)
            {
                return(sw.ClassName == "Progman" && sw.Title == "Program Manager" && sw.Process.ProcessName == "explorer");
            });
            if (sws.Length != 1)
            {
                MessageBox.Show("Could not find Desktop window");
                return(null);
            }
            sws = sws[0].FilterDescendantWindows(false, delegate(SystemWindow sw)
            {
                return(sw.ClassName == "SysListView32" && sw.Title == "FolderView");
            });
            if (sws.Length != 1)
            {
                MessageBox.Show("Could not find Desktop window");
                return(null);
            }
            SystemListView slv = SystemListView.FromSystemWindow(sws[0]);

            if (slv == null)
            {
                MessageBox.Show("No desktop icons found");
            }
            return(slv);
        }
コード例 #4
0
 private static SystemWindow?findDesktopIconsWindow()
 {
     return(SystemWindow
            .FilterToplevelWindows(window => window.ClassName == "WorkerW" || window.ClassName == "Progman")
            .SelectMany(parent => parent.FilterDescendantWindows(true, child => child.ClassName == "SHELLDLL_DefView"))
            .SelectMany(parent => parent.FilterDescendantWindows(true, child => child.ClassName == "SysListView32"))
            .FirstOrDefault());
 }
コード例 #5
0
 private void onWindowClosed(bool firstRun = false)
 {
     if (firstRun || timer.Enabled)
     {
         timer.Enabled = SystemWindow.FilterToplevelWindows(isGitExtensionsMainWindow).Any();
         LOGGER.Trace("Starting up or a window was closed, timer is {0}", timer.Enabled ? "enabled" : "disabled");
     }
 }
コード例 #6
0
ファイル: Program.cs プロジェクト: hu13779472390/MakeTopMost
        public ContextMenu CreateMenu()
        {
            SystemWindow foregroundWindow = SystemWindow.ForegroundWindow;

            return(new ContextMenu(SystemWindow.FilterToplevelWindows(window => window.Visible && !string.IsNullOrWhiteSpace(window.Title) && window != foregroundWindow && window.Process.ProcessName != "explorer")
                                   .Select(window => new SystemWindowMenuItem(window))
                                   .Concat(new MenuItem[] { new MenuItem("-"), new MenuItem("E&xit", (s, e) => Application.Exit(), Shortcut.AltF4) }).ToArray()));
        }
コード例 #7
0
 public static bool CheckConnect(string Host, int ForwardPort)
 {
     SystemWindow[] winscheck = SystemWindow.FilterToplevelWindows((SystemWindow w) => { return(w.Title == "Bitvise SSH Client - " + ForwardPort + ".bscp - " + Host + ":22"); });
     if (winscheck.Length > 0)
     {
         return(true);
     }
     return(false);
 }
コード例 #8
0
ファイル: MainForm.cs プロジェクト: zouhao485/mwinapi
 private void kbdButton_Click(object sender, EventArgs e)
 {
     kbdControls.Visible = !kbdControls.Visible;
     kbdButton.Text      = kbdControls.Visible ? "<< &Keyboard" : "&Keyboard >>";
     this.Height         = kbdControls.Visible ? 354 : 127;
     if (kbdControls.Visible)
     {
         windowBox.Items.Clear();
         windowBox.Items.AddRange(SystemWindow.FilterToplevelWindows(delegate(SystemWindow sw) { return(sw.Visible); }));
     }
 }
コード例 #9
0
        private void OnActivated(object sender, EventArgs e)
        {
            var windows = SystemWindow.FilterToplevelWindows(new Predicate <SystemWindow>(IsAppWindow));

            Array.Sort(windows, (wnd1, wnd2) => wnd1.Title.CompareTo(wnd2.Title));

            //
            // If an item was already selected in the list, try to find it in the new list and
            // select it.
            //

            var selectedWindow = WindowList.SelectedItem as SystemWindow;

            m_Windows.Clear();
            m_Windows.AddRange(windows);

            WindowList.Items.Refresh();
            CollectionViewSource.GetDefaultView(WindowList.ItemsSource).Refresh();

            //
            // If the previously selected window is not found in the new list, simply select
            // the first element.
            //

            int selectIndex = 0;

            if (selectedWindow != null)
            {
                for (int i = 0; i < WindowList.Items.Count; ++i)
                {
                    SystemWindow wnd = WindowList.Items[i] as SystemWindow;
                    if (wnd.HWnd == selectedWindow.HWnd)
                    {
                        selectIndex = i;
                        break;
                    }
                }
            }

            if (!WindowList.Items.IsEmpty)
            {
                WindowList.SelectedIndex = selectIndex;
                WindowList.UpdateLayout();
                (WindowList.ItemContainerGenerator.ContainerFromIndex(selectIndex) as ListViewItem).Focus();
            }

            FuzzySearchTitle.Focus();
        }
コード例 #10
0
        private void findCommitWindows(object?sender = null, ElapsedEventArgs?elapsedEventArgs = null)
        {
            ISet <SystemWindow> foundWindows = new HashSet <SystemWindow>(SystemWindow.FilterToplevelWindows(window =>
                                                                                                             window.ClassName == "WindowsForms10.Window.8.app.0.2bf8098_r7_ad1" && window.Title.StartsWith("Commit")));

            ISet <SystemWindow> newWindows = new HashSet <SystemWindow>(foundWindows);

            newWindows.ExceptWith(_commitWindows);

            _commitWindows = foundWindows;

            LOGGER.Trace("Found {0} commit windows, {1} of them new.", _commitWindows.Count, newWindows.Count);

            foreach (SystemWindow newWindow in newWindows)
            {
                SpinWait.SpinUntil(() => newWindow.VisibilityFlag, 500); //commit windows are sometimes created with visibilityflag=false briefly, which prevents our automatic resizing (intentionally), so wait for up to 0.5 seconds for it to become visible before triggering callbacks
                commitWindowOpened?.Invoke(newWindow);
            }
        }
コード例 #11
0
        public IEnumerable <SystemWindow> findResizableWindows(SystemWindow?parent = null, int depth = 1)
        {
            if (depth <= 0)
            {
                yield break;
            }

            SystemWindow[] children = parent == null
                ? SystemWindow.FilterToplevelWindows(canWindowBeAutomaticallyResized)
                : parent.FilterDescendantWindows(true, canWindowBeAutomaticallyResized);

            foreach (SystemWindow child in children)
            {
                yield return(child);
            }

            foreach (SystemWindow child in children)
            {
                foreach (var grandChild in findResizableWindows(child, depth - 1))
                {
                    yield return(grandChild);
                }
            }
        }
コード例 #12
0
 /// <summary>
 /// Refreshes list of window titles by requerying list of top-level windows
 /// </summary>
 public void RefreshWindowTitles()
 {
     this.DataSource = SystemWindow.FilterToplevelWindows(FilterWindows);
 }
コード例 #13
0
ファイル: QuikTerminal.cs プロジェクト: valmac/Trading
 IEnumerable <SystemWindow> GetQuikWindows(Process process)
 {
     return(SystemWindow.FilterToplevelWindows(wnd => wnd.Process.Id == process.Id));
 }
コード例 #14
0
        public static bool Connect(string Host, string User, string Pass, int ForwardPort, int TimeoutSeconds, bool hidebitvise = true)
        {
            bool Connected = false;

            //Start Bitvise - Auto Login
            ProcessStartInfo sinfo = new ProcessStartInfo();

            //sinfo.FileName = AppDomain.CurrentDomain.BaseDirectory + "Bitvise\\BvSsh.exe";
            //sinfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory + "Bitvise";
            sinfo.FileName         = Application.StartupPath + "\\Bitvise\\BvSsh.exe";
            sinfo.WorkingDirectory = Application.StartupPath + "\\Bitvise";
            if (hidebitvise)
            {
                sinfo.Arguments = "-noRegistry -profile=\"" + Application.StartupPath + "\\Bitvise\\Profiles\\" + ForwardPort + ".bscp\" -host=" + Host + " -user="******" -password="******" -loginOnStartup -hide=trayIcon";
            }
            else
            {
                sinfo.Arguments = "-noRegistry -profile=\"" + Application.StartupPath + "\\Bitvise\\Profiles\\" + ForwardPort + ".bscp\" -host=" + Host + " -user="******" -password="******" -loginOnStartup";
            }

            Process BitviseApp = Process.Start(sinfo);

            BitviseList[ForwardPort] = BitviseApp;

            Thread.Sleep(2000);
            //Bitvise Login Checking...
            for (int i = 0; i < TimeoutSeconds; i++)
            {
                //Detect Host Key Verification
                SystemWindow[] wins = SystemWindow.FilterToplevelWindows((SystemWindow w) => { return(w.Title == "Host Key Verification"); });
                if (wins.Length > 0)
                {
                    SystemWindow[] wins2 = wins[0].FilterDescendantWindows(false, (SystemWindow w) => { return(w.Title == "&Accept for This Session"); });    //Accept and &Save
                    if (wins2.Length > 0)
                    {
                        //Click 4 times to effected !
                        SendMessage((int)wins2[0].HWnd, WM_LBUTTONDOWN, 0, IntPtr.Zero);
                        Thread.Sleep(10);
                        SendMessage((int)wins2[0].HWnd, WM_LBUTTONUP, 0, IntPtr.Zero);

                        SendMessage((int)wins2[0].HWnd, WM_LBUTTONDOWN, 0, IntPtr.Zero);
                        Thread.Sleep(10);
                        SendMessage((int)wins2[0].HWnd, WM_LBUTTONUP, 0, IntPtr.Zero);
                    }
                }

                //Detect Connected
                SystemWindow[] wins3 = SystemWindow.FilterToplevelWindows((SystemWindow w) => { return(w.Title == "Bitvise SSH Client - " + ForwardPort + ".bscp - " + Host + ":22"); });
                if (wins3.Length > 0)
                {
                    Connected = true;
                    break;
                }
                Thread.Sleep(1000);
            }

            if (Connected == false)
            {
                try
                {
                    BitviseApp.Kill();
                    BitviseApp.Dispose();
                }
                catch { }
            }


            return(Connected);
        }