示例#1
0
 /// <summary>
 /// Simulation of pressed key.
 /// </summary>
 /// <param name="hWnd">Window handle to send key to</param>
 /// <param name="key">Key code</param>
 public static void PressKey(IntPtr hWnd, WinApi.VirtualKeys key)
 {
     WinApi.PostMessage(hWnd, WinApi.WM_KEYDOWN, (UInt32)key, IntPtr.Zero);
     Thread.Sleep(50 + random.Next(-10, 35));
     WinApi.PostMessage(hWnd, WinApi.WM_KEYUP, (UInt32)key, IntPtr.Zero);
 }
示例#2
0
 /// <summary>
 /// Simulate left mouse button click
 /// </summary>
 /// <param name="hWnd">Window handle to send key to</param>
 public static void MouseClickLMB(IntPtr hWnd)
 {
     WinApi.PostMessage(hWnd, WinApi.WM_LBUTTONDOWN, (UInt32)WinApi.VirtualKeys.LeftButton, IntPtr.Zero);
     Thread.Sleep(50 + random.Next(-10, 10));
     WinApi.PostMessage(hWnd, WinApi.WM_LBUTTONUP, (UInt32)WinApi.VirtualKeys.LeftButton, IntPtr.Zero);
 }