示例#1
2
 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);
     }
 }
示例#3
0
        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;
            }
        }
示例#4
0
 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));
 }
 public static void PressKey(IntPtr handle, WMessages msg, params Keys[] keys)
 {
     foreach (var k in keys)
     {
         SendMessage(handle, (uint)msg, (IntPtr)k,
             IntPtr.Zero);
     }
 }