// 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); }
internal Win32Rect(Win32Rect rcSrc) { this.left = rcSrc.left; this.top = rcSrc.top; this.right = rcSrc.right; this.bottom = rcSrc.bottom; }
internal Win32Rect(Win32Rect rcSrc) { left = rcSrc.left; top = rcSrc.top; right = rcSrc.right; bottom = rcSrc.bottom; }
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); }
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(); } }
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); }
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); }
internal Win32Rect(Win32Rect rcSrc) { this.left = rcSrc.left; this.top = rcSrc.top; this.right = rcSrc.right; this.bottom = rcSrc.bottom; }
static extern bool GetWindowRect (IntPtr hwnd, out Win32Rect rect);
static extern int DwmGetWindowAttribute (IntPtr hwnd, DwmWindowAttribute attribute, out Win32Rect value, int valueSize);
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; }
public static extern int GetRgnBox(IntPtr hrgn, ref Win32Rect lprc);
internal COMBOBOXINFO(int size) { cbSize = size; rcItem = Win32Rect.Empty; rcButton = Win32Rect.Empty; stateButton = 0; hwndCombo = IntPtr.Zero; hwndItem = IntPtr.Zero; hwndList = IntPtr.Zero; }
public static extern int GetRgnBox(IntPtr hrgn, ref Win32Rect lprc);
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); }
static extern bool GetWindowRect(IntPtr hWnd, ref Win32Rect lpRect);
static extern int DwmGetWindowAttribute(IntPtr hwnd, DwmWindowAttribute attribute, out Win32Rect value, int valueSize);
static extern bool GetWindowRect(IntPtr hwnd, out Win32Rect rect);
public static extern int FillRect(IntPtr hdc, ref Win32Rect rect, IntPtr hBrush);
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; }
public static extern bool GetClientRect(IntPtr hWnd, out Win32Rect rect);
public static extern int FillRect(IntPtr hdc, ref Win32Rect rect, IntPtr hBrush);
private static extern bool GetWindowRect(IntPtr hwnd, out Win32Rect lpRect);
private static extern bool MagSetWindowSource(IntPtr hWnd, Win32Rect rect);
public static extern bool GetWindowRect(IntPtr hWnd, out Win32Rect lprect);