Exemplo n.º 1
0
        //This simulates a left mouse click
        public void LeftMouseClick(int xpos, int ypos)
        {
            User32.Rect rect = new User32.Rect();

            User32.GetWindowRect(WinPtr, ref rect);

            User32.SetCursorPos(rect.left + xpos, rect.top + ypos);

            Thread.Sleep(100);

            User32.mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
            User32.mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
        }
Exemplo n.º 2
0
        public Bitmap GetScreenPart(int top, int left, int width, int height)
        {
            User32.Rect rect = new User32.Rect();

            User32.GetWindowRect(WinPtr, ref rect);

            var      bmp      = new Bitmap(width, height, PixelFormat.Format32bppArgb);
            Graphics graphics = Graphics.FromImage(bmp);

            graphics.CopyFromScreen(rect.left + left, rect.top + top, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);

            //bmp.Save("c:\\tmp\\test.png", ImageFormat.Png);

            return(bmp);
        }