public async Task RightClickMouse(Point p) { SetCursorPosition(p); var pp = new PInvoke.POINT { x = p.X, y = p.Y }; NativeMethods.ScreenToClient(process.MainWindowHandle, ref pp); int lparam = NativeMethods.MakeLParam(pp.x, pp.y); NativeMethods.PostMessage(process.MainWindowHandle, NativeMethods.WM_RBUTTONDOWN, 0, lparam); await Delay(MIN_DELAY); NativeMethods.GetCursorPos(out p); pp = new PInvoke.POINT { x = p.X, y = p.Y }; NativeMethods.ScreenToClient(process.MainWindowHandle, ref pp); lparam = NativeMethods.MakeLParam(pp.x, pp.y); NativeMethods.PostMessage(process.MainWindowHandle, NativeMethods.WM_RBUTTONUP, 0, lparam); }
static void GetControlRect(IntPtr hWnd, IntPtr controlHWND, out PInvoke.RECT rect) { PInvoke.GetWindowRect(controlHWND, out rect); var pt = new PInvoke.POINT(rect.Left, rect.Top); PInvoke.ScreenToClient(hWnd, ref pt); rect.Right = rect.Right - rect.Left + pt.X; rect.Bottom = rect.Bottom - rect.Top + pt.Y; rect.Left = pt.X; rect.Top = pt.Y; }
public void Init() { m_SystemDoubleClickTime = GetDoubleClickTime(); m_SystemDragX = GetSystemMetrics(SystemMetric.SM_CXDRAG); m_SystemDragY = GetSystemMetrics(SystemMetric.SM_CYDRAG); PInvoke.POINT mousePoint = GetCursorPos(); m_PreviousX = mousePoint.x; m_PreviousY = mousePoint.y; HookHelper.instance.HookGlobalMouse(HookMouseCallback); }
public static MorphicResult <Point, Win32ApiError> GetCurrentPosition() { var point = new PInvoke.POINT(); var getCursorPosResult = PInvoke.User32.GetCursorPos(out point); if (getCursorPosResult == false) { var win32ErrorCode = PInvoke.Kernel32.GetLastError(); if (win32ErrorCode != PInvoke.Win32ErrorCode.ERROR_SUCCESS) { return(MorphicResult.ErrorResult(Win32ApiError.Win32Error((uint)win32ErrorCode))); } } var result = new Point(point.x, point.y); return(MorphicResult.OkResult(result)); }
public static Point GetCursorPosition() { PInvoke.POINT pos = GetCursorPos(); return(new Point(pos.x, pos.y)); }
static void GetControlRect(IntPtr hWnd, IntPtr controlHWND, out PInvoke.RECT rect) { PInvoke.GetWindowRect(controlHWND, out rect); var pt = new PInvoke.POINT(rect.Left, rect.Top); PInvoke.ScreenToClient(hWnd, ref pt); rect.Right = rect.Right - rect.Left + pt.X; rect.Bottom = rect.Bottom - rect.Top + pt.Y; rect.Left = pt.X; rect.Top = pt.Y; }