Example #1
0
        public Bitmap CaptureWindow(IntPtr hWnd)
        {
            WinAPI.RECT rctForm = new WinAPI.RECT();
            WinAPI.GetWindowRect(hWnd, out rctForm);

            Bitmap   pImage   = new System.Drawing.Bitmap(rctForm.Width, rctForm.Height);
            Graphics graphics = System.Drawing.Graphics.FromImage(pImage);
            IntPtr   hDC      = graphics.GetHdc();

            //paint control onto graphics using provided options
            try
            {
                WinAPI.PrintWindow(hWnd, hDC, (uint)1);
            }
            finally
            {
                graphics.ReleaseHdc(hDC);
            }
            return(pImage);
        }
Example #2
0
        private void mouseHook_LeftButtonUp(WinAPI.MSLLHOOKSTRUCT mouseStruct)
        {
            // Wait for the pinball browser window to be updated
            Thread.Sleep(100);

            if (wndPinballBrowser != IntPtr.Zero && WinAPI.IsWindow(wndPinballBrowser))
            {
                // Get the capture window rectangle
                WinAPI.RECT wndRect = new WinAPI.RECT();
                WinAPI.GetWindowRect(wndPinballBrowser, out wndRect);

                // Capture only if mouse is on the advance frame button in Pinball Browser
                if (mouseStruct.pt.x >= (wndRect.X + 246) &&
                    mouseStruct.pt.y >= (wndRect.Y - 72) &&
                    mouseStruct.pt.x <= (wndRect.X + 246 + 17) &&
                    mouseStruct.pt.y <= (wndRect.Y - 72 + 24))
                {
                    Import();
                }
            }
        }