Advertisement
Guest User

Double Clicking

a guest
Jul 6th, 2014
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. [System.Runtime.InteropServices.DllImport("user32.dll")]
  2. static extern bool SetCursorPos(int x, int y);
  3.  
  4. [System.Runtime.InteropServices.DllImport("user32.dll")]
  5. public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
  6.  
  7. public const int MOUSEEVENTF_LEFTDOWN = 0x02;
  8. public const int MOUSEEVENTF_LEFTUP = 0x04;
  9.  
  10. //This simulates a left mouse click
  11. public static void LeftMouseClick(int xpos, int ypos)
  12. {
  13.     SetCursorPos(xpos, ypos);
  14.     mouse_event(MOUSEEVENTF_LEFTDOWN, xpos, ypos, 0, 0);
  15.     mouse_event(MOUSEEVENTF_LEFTUP, xpos, ypos, 0, 0);
  16. }
  17.  
  18. private void button1_Click(object sender, EventArgs e)
  19. {
  20.     HookToS1();         //Hook to the process, see Github for complete method
  21.     SetForegroundWindow(s1);    //See above
  22.  
  23.     //while (true)      //Loop to get cursor position
  24.     //Console.WriteLine(Cursor.Position);
  25.  
  26.     //Method x2 to double click. It works!
  27.     LeftMouseClick(-900, 660);
  28.     LeftMouseClick(-900, 660);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement