code_junkie

Ui automation testing right click menus

Nov 12th, 2011
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. public static class Mouse
  2. {
  3.  
  4. private const UInt32 MouseEventLeftDown = 0x0002;
  5. private const UInt32 MouseEventLeftUp = 0x0004;
  6. private const UInt32 MouseEventRightDown = 0x0008;
  7. private const UInt32 MouseEventRightUp = 0x00010;
  8.  
  9.  
  10. [DllImport("user32.dll")]
  11.  
  12. private static extern void mouse_event(UInt32 dwFlags, UInt32 dx, UInt32 dy, UInt32 dwData, IntPtr dwExtraInfo);
  13.  
  14.  
  15.  
  16. public static void Click()
  17. {
  18. mouse_event(MouseEventLeftDown, 0, 0, 0, IntPtr.Zero);
  19. mouse_event(MouseEventLeftUp, 0, 0, 0, IntPtr.Zero);
  20. Thread.Sleep(100);
  21. }
  22.  
  23. public static void RightClick()
  24. {
  25. mouse_event(MouseEventRightDown, 0, 0, 0, IntPtr.Zero);
  26. mouse_event(MouseEventRightUp, 0, 0, 0, IntPtr.Zero);
  27. Thread.Sleep(100);
  28.  
  29. }
Add Comment
Please, Sign In to add comment