C# WinAPI - MoveWindow
using System.Runtime.InteropServices; [DllImport("user32.dll")] private static extern bool MoveWindow(IntPtr hWnd, int X, int Y, uint nWidth, uint nHeight, bool bRepaint); private void MoveWinResize(IntPtr hWnd, int X, int Y, uint nWidth, uint nHeight, bool bRepaint = true) { MoveWindow(hWnd, X, Y, nWidth, nHeight, bRepaint); }
C# WinAPI - SendMessage MouseClick
using System.Runtime.InteropServices; [DllImport("user32.dll")] private static extern int SendMessage(IntPtr hwnd, uint wMsg, int wParam, IntPtr lParam); private void SendClick(IntPtr handle, int X, int Y) { SendMessage(handle, (uint)WMessages.WM_LBUTTONDOWN, 1, new IntPtr(Y * 0x10000 + X)); SendMessage(handle, (uint)WMessages.WM_LBUTTONUP, 0, new IntPtr(Y * 0x10000 + X)); }
C# WinAPI - PostMessage MouseClick
using System.Runtime.InteropServices; [DllImport("user32.dll")] private static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, IntPtr lParam); private void MouseClick(IntPtr handle, int X, int Y) { PostMessage(handle, (uint)WMessages.WM_LBUTTONDOWN, 1, new IntPtr(Y * 0x10000 + X)); PostMessage(handle, (uint)WMessages.WM_LBUTTONUP, 0, new IntPtr(Y * 0x10000 + X)); }