コード例 #1
0
        private bool EnumWindowsCallback(IntPtr hWnd, IntPtr lParam)
        {
            int style   = ExternalAPI.GetWindowLong(hWnd, -16);
            int Exstyle = ExternalAPI.GetWindowLong(hWnd, -20);

            if (!ExternalAPI.IsWindowVisible(hWnd))
            {
                return(true);
            }

            // Ignore Popup windows
            if ((style & 0x80000000) != 0)
            {
                return(true);
            }

            uint          ProcessID;
            StringBuilder TempString = new StringBuilder();

            ExternalAPI.GetWindowThreadProcessId(hWnd, out ProcessID);

            IntPtr ProcessHandle = ExternalAPI.OpenProcess(0x0400, false, ProcessID);

            TempString.EnsureCapacity(1024);
            ExternalAPI.GetModuleFileNameEx(ProcessHandle, IntPtr.Zero, TempString, TempString.Capacity);

            if (TempString.ToString() == System.Reflection.Assembly.GetExecutingAssembly().Location)
            {
                return(true);
            }

            WindowData Entry;

            Entry.Handle = hWnd;
            Entry.Name   = System.IO.Path.GetFileNameWithoutExtension(TempString.ToString());

            ExternalAPI.CloseHandle(ProcessHandle);

            int size = ExternalAPI.GetWindowTextLength(hWnd);

            if (size != 0)
            {
                TempString.EnsureCapacity(size + 1);
                ExternalAPI.GetWindowText(hWnd, TempString, TempString.Capacity);

                Entry.Title = TempString.ToString();
            }
            else
            {
                Entry.Title = "";
            }

            WindowDropdown.Items.Add(Entry);

            return(true);
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: FoxCutter/Tools
            public bool EnumWindowsCallback(IntPtr hWnd, IntPtr lParam)
            {
                int style   = ExternalAPI.GetWindowLong(hWnd, -16);
                int Exstyle = ExternalAPI.GetWindowLong(hWnd, -20);

                if (!ExternalAPI.IsWindowVisible(hWnd))
                {
                    return(true);
                }

                // Ignore Popup windows
                if ((style & 0x80000000) != 0)
                {
                    return(true);
                }

                uint          ProcessID;
                StringBuilder TempString = new StringBuilder();

                ExternalAPI.GetWindowThreadProcessId(hWnd, out ProcessID);

                IntPtr ProcessHandle = ExternalAPI.OpenProcess(0x0400, false, ProcessID);

                TempString.EnsureCapacity(1024);
                ExternalAPI.GetModuleFileNameEx(ProcessHandle, IntPtr.Zero, TempString, TempString.Capacity);
                ExternalAPI.CloseHandle(ProcessHandle);

                string ExeName = System.IO.Path.GetFileNameWithoutExtension(TempString.ToString());

                if (Name.Equals(ExeName, StringComparison.InvariantCultureIgnoreCase))
                {
                    if (MatchTitle)
                    {
                        int size = ExternalAPI.GetWindowTextLength(hWnd);
                        if (size != 0)
                        {
                            TempString.EnsureCapacity(size + 1);
                            ExternalAPI.GetWindowText(hWnd, TempString, TempString.Capacity);

                            if (TempString.ToString() == Title)
                            {
                                Handle = hWnd;
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        Handle = hWnd;
                        return(false);
                    }
                }

                return(true);
            }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: FoxCutter/Tools
        public void UpdateThread()
        {
            while (true)
            {
                if (SettingOptionsWindow.Visible)
                {
                    System.Threading.Thread.Sleep(SettingOptionsWindow.CaptureRate);
                }
                else
                {
                    System.Threading.Thread.Sleep(CaptureRate);
                }

                if (CaptureOptionsWindow.Visible)
                {
                    continue;
                }

                // Only look up the Window if we don't have one, or if the one we have is no longer a window or is hidden
                if (MatchWindowHandle == IntPtr.Zero || !ExternalAPI.IsWindow(MatchWindowHandle) || !ExternalAPI.IsWindowVisible(MatchWindowHandle))
                {
                    bool A = ExternalAPI.IsWindow(MatchWindowHandle);
                    bool B = ExternalAPI.IsWindowVisible(MatchWindowHandle);

                    MatchWindowHandle = FindWindow(WindowName, WindowTitle, MatchWindowTitle);
                }

                if (TopmostOnly && ExternalAPI.GetForegroundWindow() != MatchWindowHandle)
                {
                    continue;
                }

                Bitmap Image = null;
                if (MatchWindowHandle != IntPtr.Zero)
                {
                    Image = ExternalAPI.CaptureWindow(MatchWindowHandle, Method);
                }

                this.Invoke(UpdateCaptureCallback, Image);
            }
        }