public static async Task ClickAsync(IntPtr windowHandle, int x, int y, TimeSpan delayButtonUp)
        {
            User32NativeMethods.SendMessage(windowHandle, User32NativeMethods.WM_MOUSEMOVE, IntPtr.Zero, WinAPI.CreateLParam(x, y));
            User32NativeMethods.SendMessage(windowHandle, User32NativeMethods.WM_LBUTTONDOWN, new IntPtr(User32NativeMethods.MK_LBUTTON), WinAPI.CreateLParam(x, y));
            await Task.Delay(delayButtonUp);

            User32NativeMethods.SendMessage(windowHandle, User32NativeMethods.WM_LBUTTONUP, new IntPtr(User32NativeMethods.MK_LBUTTON), WinAPI.CreateLParam(x, y));
        }
Exemple #2
0
 public void MinimizeWindow(IntPtr handle, bool enableAnimation)
 {
     if (enableAnimation)
     {
         User32NativeMethods.SendMessage(handle, InteropConstants.WM_SYSCOMMAND, InteropConstants.SC_MINIMIZE, 0);
     }
     else
     {
         WINDOWPLACEMENT param = new WINDOWPLACEMENT();
         param.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
         User32NativeMethods.GetWindowPlacement(handle, ref param);
         param.showCmd = WINDOWPLACEMENT.SW_MINIMIZE;
         User32NativeMethods.SetWindowPlacement(handle, ref param);
     }
 }
 public static void Click(IntPtr windowHandle, int x, int y)
 {
     User32NativeMethods.SendMessage(windowHandle, User32NativeMethods.WM_MOUSEMOVE, IntPtr.Zero, WinAPI.CreateLParam(x, y));
     User32NativeMethods.SendMessage(windowHandle, User32NativeMethods.WM_LBUTTONDOWN, new IntPtr(User32NativeMethods.MK_LBUTTON), WinAPI.CreateLParam(x, y));
     User32NativeMethods.SendMessage(windowHandle, User32NativeMethods.WM_LBUTTONUP, new IntPtr(User32NativeMethods.MK_LBUTTON), WinAPI.CreateLParam(x, y));
 }
 public static void Move(IntPtr windowHandle, int x, int y)
 {
     User32NativeMethods.SendMessage(windowHandle, User32NativeMethods.WM_MOUSEMOVE, IntPtr.Zero, WinAPI.CreateLParam(x, y));
 }