Esempio n. 1
0
        public static Point GetCoordinateRelativeToWindow(IntPtr hWnd)
        {
            Structs.Rect rect = default(Structs.Rect);
            WinAPI.GetWindowRect(hWnd, out rect);
            Point position = Cursor.Position;
            int   x        = position.X;

            position = Cursor.Position;
            int y = position.Y;

            return(new Point(x - rect.X, y - rect.Y));
        }
Esempio n. 2
0
        public static Bitmap Screenshot(IntPtr hWnd)
        {
            Normalize(hWnd);
            Structs.Rect rect;
            WinAPI.GetWindowRect(hWnd, out rect);
            Bitmap   bitmap   = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb);
            Graphics graphics = Graphics.FromImage(bitmap);
            IntPtr   hdc      = graphics.GetHdc();

            WinAPI.PrintWindow(hWnd, hdc, 0);
            graphics.ReleaseHdc(hdc);
            graphics.Dispose();
            return(bitmap);
        }
Esempio n. 3
0
        public static void HideTaskBar()
        {
            //IntPtr desktopWindow = WinAPI.GetDesktopWindow();
            //IntPtr hWnd = WinAPI.FindWindowEx(desktopWindow, 0, "button", 0);
            //IntPtr hWnd2 = WinAPI.FindWindowEx(desktopWindow, 0, "Shell_TrayWnd", 0);
            //WinAPI.SetWindowPos(hWnd, 0, 0, 0, 0, 0, 128);
            //WinAPI.SetWindowPos(hWnd2, 0, 0, 0, 0, 0, 128);

            IntPtr    desktopWindow = WinAPI.GetDesktopWindow();
            IntPtr    hWnd          = WinAPI.FindWindowEx(desktopWindow, 0, "button", 0);
            Rectangle rec           = new Rectangle();
            var       windowRec     = WinAPI.GetWindowRect(hWnd, out rec);

            WinAPI.SetWindowPos(hWnd, 0, Screen.AllScreens[1].WorkingArea.Left, Screen.AllScreens[1].WorkingArea.Top, rec.Size.Width, rec.Size.Height, 0x0001 | 0x0040);
        }
Esempio n. 4
0
 public static Point ConvertToWindowCoordinates(IntPtr hWnd, int x, int y)
 {
     Structs.Rect rect = default(Structs.Rect);
     WinAPI.GetWindowRect(hWnd, out rect);
     return(new Point(rect.X + x, rect.Y + y));
 }
Esempio n. 5
0
 public static Rectangle GetDimensions(IntPtr hWnd)
 {
     Structs.Rect rect = default(Structs.Rect);
     WinAPI.GetWindowRect(hWnd, out rect);
     return(new Rectangle(rect.X, rect.Y, rect.Width, rect.Height));
 }