Example #1
0
        private static void Mouse_Click(NativeRECT menuRec)
        {
            Point menPos = new Point();

            menPos.X = (menuRec.right + menuRec.left) / 2;
            menPos.Y = (menuRec.top + menuRec.bottom) / 2;
            SetCursorPos(menPos.X, menPos.Y);
            mouse_event(MouseEventFlag.LeftDown | MouseEventFlag.LeftUp, 0, 0, 1, UIntPtr.Zero);//模拟单击
        }
Example #2
0
 public static extern bool GetWindowRect(HandleRef hwnd, out NativeRECT rect);
Example #3
0
 private static extern bool GetWindowRect(IntPtr hwnd, ref NativeRECT rect);
Example #4
0
        private void dt_Tick(object sender, EventArgs e)
        {
            rect = new NativeRECT();
            fd1 = FindWindow("minesweeper", "扫雷");
            fd = FindWindowEx(fd1, IntPtr.Zero, "static", string.Empty);
            if (fd==IntPtr.Zero) {
                Image1.Source=_defaultSource;
                Image1.Cursor = Cursors.Hand;
                bitmap=null;
                return;
            }
            Image1.Cursor = Cursors.Arrow;

            GetWindowRect(fd, ref rect);

            int h = rect.bottom - rect.top;
            int w = rect.right-rect.left;
            Rectangle r = new Rectangle(rect.left, rect.top, w, h);

            bitmap = new Bitmap(w, h, PixelFormat.Format32bppArgb);
            using (Graphics g = Graphics.FromImage(bitmap)) {
                g.CopyFromScreen(r.Left, r.Top, 0, 0, r.Size, CopyPixelOperation.SourceCopy);
            }
            IntPtr ip = bitmap.GetHbitmap();
            BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                ip, IntPtr.Zero, Int32Rect.Empty,
                BitmapSizeOptions.FromEmptyOptions());
            DeleteObject(ip);
            Image1.Source = bitmapSource;
        }
Example #5
0
 private static extern bool GetMenuItemRect(IntPtr hwnd, IntPtr hMenu, int posMenu, out NativeRECT rect);