Ejemplo n.º 1
0
        // this accounts for the border and shadow. Serious fudgery here.
        private static Int32Rect GetWindowActualRect(IntPtr hWnd)
        {
            Win32Rect windowRect = new Win32Rect();
            Win32Rect clientRect = new Win32Rect();

            User32.GetWindowRect(hWnd, out windowRect);
            User32.GetClientRect(hWnd, out clientRect);

            int sideBorder = (windowRect.Width - clientRect.Width) / 2 + 1;

            // sooo, yeah.
            const int hackToAccountForShadow = 4;

            Win32Point topLeftPoint = new Win32Point(windowRect.Left - sideBorder, windowRect.Top - sideBorder);

            //User32.ClientToScreen(hWnd, ref topLeftPoint);

            Int32Rect actualRect = new Int32Rect(
                topLeftPoint.X,
                topLeftPoint.Y,
                windowRect.Width + sideBorder * 2 + hackToAccountForShadow,
                windowRect.Height + sideBorder * 2 + hackToAccountForShadow);

            return(actualRect);
        }
Ejemplo n.º 2
0
 internal Win32Rect(Win32Rect rcSrc)
 {
     this.left   = rcSrc.left;
     this.top    = rcSrc.top;
     this.right  = rcSrc.right;
     this.bottom = rcSrc.bottom;
 }
Ejemplo n.º 3
0
 internal Win32Rect(Win32Rect rcSrc)
 {
     left   = rcSrc.left;
     top    = rcSrc.top;
     right  = rcSrc.right;
     bottom = rcSrc.bottom;
 }
Ejemplo n.º 4
0
            public static Win32Rect FromRTLB(int left, int top, int right, int bottom)
            {
                Win32Rect rect = new Win32Rect();

                rect.Left   = left;
                rect.Top    = top;
                rect.Right  = right;
                rect.Bottom = bottom;
                return(rect);
            }
Ejemplo n.º 5
0
        public void SetRegion(Dimensions region)
        {
            _region = new Win32Rect
            {
                Left   = (int)region.Left,
                Top    = (int)region.Top,
                Right  = (int)region.Right,
                Bottom = (int)region.Bottom
            };

            if (_isRestricted)
            {
                RestrictMouseToRegion();
            }
        }
Ejemplo n.º 6
0
        private static void WmGetMinMaxInfo(IntPtr hwnd, IntPtr param)
        {
            // Adjust the maximized size and position to fit the work area of the correct monitor
            IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

            var minMax = (MinMaxInfo)Marshal.PtrToStructure(param, typeof(MinMaxInfo));

            if (monitor != IntPtr.Zero)
            {
                var monitorInfo = new MonitorInfo();
                GetMonitorInfo(monitor, monitorInfo);
                Win32Rect workArea    = monitorInfo.WorkArea;
                Win32Rect monitorArea = monitorInfo.Monitor;
                minMax.MaxPosition = new Win32Point(workArea.Left - monitorArea.Left, workArea.Left - monitorArea.Left);
                minMax.MaxSize     = new Win32Point(workArea.Right - workArea.Left, workArea.Bottom - workArea.Top);
            }

            Marshal.StructureToPtr(minMax, param, true);
        }
Ejemplo n.º 7
0
        private Rectangle?FindSynthesisButton()
        {
            // Grab the location and size information for the FFXIV window.
            Win32Rect ffScreenRect = new Win32Rect();

            GetWindowRect(this.FFWindowHandle, ref ffScreenRect);
            var screenSize = new Size(ffScreenRect.Right - ffScreenRect.Left, ffScreenRect.Bottom - ffScreenRect.Top);

            // Create a GDI+ interface and take a screen shot of the screen.
            using (Graphics ffScreen = Graphics.FromHwnd(this.FFWindowHandle))
            {
                using (Bitmap screenShot = new Bitmap(screenSize.Width, screenSize.Height, ffScreen))
                {
                    using (Graphics screenShotInterface = Graphics.FromImage(screenShot))
                    {
                        screenShotInterface.CopyFromScreen(ffScreenRect.Left, ffScreenRect.Top, 0, 0, screenSize);
                    }

                    // Use the screen shot and find any likely matches.
                    Image <Gray, byte> source = new Image <Gray, byte>(screenShot);
                    using (Image <Gray, float> result = source.MatchTemplate(this._synthButtonImage, Emgu.CV.CvEnum.TemplateMatchingType.CcoeffNormed))
                    {
                        double[] minValues, maxValues;
                        System.Drawing.Point[] minLocations, maxLocations;
                        result.MinMax(out minValues, out maxValues, out minLocations, out maxLocations);

                        // Check the max value, only feel confident if it's over 0.8.
                        if (maxValues.Any() && maxValues[0] > 0.8)
                        {
                            return(new Rectangle(maxLocations[0].X, maxLocations[0].Y, this._synthButtonImage.Width, this._synthButtonImage.Height));
                        }
                    }
                }
            }

            // If we got here we didn't find any likely matches.
            return(null);
        }
Ejemplo n.º 8
0
 internal Win32Rect(Win32Rect rcSrc)
 {
     this.left = rcSrc.left;
     this.top = rcSrc.top;
     this.right = rcSrc.right;
     this.bottom = rcSrc.bottom;
 }
Ejemplo n.º 9
0
		static extern bool GetWindowRect (IntPtr hwnd, out Win32Rect rect);
Ejemplo n.º 10
0
		static extern int DwmGetWindowAttribute (IntPtr hwnd, DwmWindowAttribute attribute, out Win32Rect value, int valueSize);
Ejemplo n.º 11
0
 public static Win32Rect FromRTLB(int left, int top, int right, int bottom)
 {
     Win32Rect rect = new Win32Rect();
     rect.Left = left;
     rect.Top = top;
     rect.Right = right;
     rect.Bottom = bottom;
     return rect;
 }
Ejemplo n.º 12
0
 public static extern int GetRgnBox(IntPtr hrgn, ref Win32Rect lprc);
Ejemplo n.º 13
0
 internal COMBOBOXINFO(int size)
 {
     cbSize = size;
     rcItem = Win32Rect.Empty;
     rcButton = Win32Rect.Empty;
     stateButton = 0;
     hwndCombo = IntPtr.Zero;
     hwndItem = IntPtr.Zero;
     hwndList = IntPtr.Zero;
 }
Ejemplo n.º 14
0
 public static extern int GetRgnBox(IntPtr hrgn, ref Win32Rect lprc);
Ejemplo n.º 15
0
 public WindowDetails(IntPtr handle, uint processId, string processPath, string title, Win32Rect rect, bool isMinimized)
 {
     Handle      = handle;
     ProcessId   = processId;
     ProcessPath = processPath;
     Title       = title;
     Width       = rect.Right - rect.Left;
     Height      = rect.Bottom - rect.Top;
     IsMinimized = isMinimized;
     ShortPath   = Path.GetFileName(processPath);
     ProcessIcon = IconGenerator.GetIcon(processPath);
 }
Ejemplo n.º 16
0
 static extern bool GetWindowRect(IntPtr hWnd, ref Win32Rect lpRect);
Ejemplo n.º 17
0
 static extern int DwmGetWindowAttribute(IntPtr hwnd, DwmWindowAttribute attribute, out Win32Rect value, int valueSize);
Ejemplo n.º 18
0
 static extern bool GetWindowRect(IntPtr hwnd, out Win32Rect rect);
Ejemplo n.º 19
0
 public static extern int FillRect(IntPtr hdc, ref Win32Rect rect, IntPtr hBrush);
Ejemplo n.º 20
0
 internal void Init(int size)
 {
     cbSize = size;
     uFlags = 0;
     hwnd = IntPtr.Zero;
     uId = 0;
     rect = Win32Rect.Empty;
     hinst = IntPtr.Zero;
     pszText = IntPtr.Zero;
     lParam = IntPtr.Zero;
 }
Ejemplo n.º 21
0
 public static extern bool GetClientRect(IntPtr hWnd, out Win32Rect rect);
Ejemplo n.º 22
0
 public static extern int FillRect(IntPtr hdc, ref Win32Rect rect, IntPtr hBrush);
Ejemplo n.º 23
0
 private static extern bool GetWindowRect(IntPtr hwnd, out Win32Rect lpRect);
Ejemplo n.º 24
0
 private static extern bool MagSetWindowSource(IntPtr hWnd, Win32Rect rect);
Ejemplo n.º 25
0
 public static extern bool GetWindowRect(IntPtr hWnd, out Win32Rect lprect);