public static void Click(IntPtr hWnd, WMessages type, Point pos) { PostMessage(new HandleRef(null, hWnd), (UInt32)type, (IntPtr)0x1, (IntPtr)((pos.Y << 16) | (pos.X & 0xFFFF))); }
public static void PressKey(IntPtr handle, WMessages msg, params Keys[] keys) { foreach (var k in keys) { SendMessage(handle, (uint)msg, (IntPtr)k, IntPtr.Zero); } }
public void SendClick(WMessages type) { Point pos = Cursor.Position; switch (type) { case WMessages.WM_LBUTTONDOWN: PostMessage(MyProcess[processIndex].MainWindowHandle, (UInt32)WMessages.WM_LBUTTONDOWN, (IntPtr)0x1, (IntPtr)((pos.Y << 16) | (pos.X & 0xFFFF))); return; case WMessages.WM_LBUTTONUP: PostMessage(MyProcess[processIndex].MainWindowHandle, (UInt32)WMessages.WM_LBUTTONUP, (IntPtr)0x1, // <--(2) but you are telling to do WM_LBUTTONDOWN (IntPtr)((pos.Y << 16) | (pos.X & 0xFFFF))); return; default: return; } }
public static extern int SendMessage( IntPtr hWnd, WMessages wMsg, char wParam, IntPtr lParam );
public static bool PostMessage(IntPtr hWnd, WMessages Msg, int wParam, int lParam) { return(SafeNativeMethods.PostMessage((int)hWnd, (uint)Msg, wParam, lParam)); }