Created
July 24, 2016 20:49
-
-
Save msadowski/06b6245949ca38ca1dbe47aed81db834 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Drawing; | |
using System.Windows.Forms; | |
using System.Runtime.InteropServices; | |
namespace BejeweledBot | |
{ | |
class VirtualMouse | |
{ | |
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] | |
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo); | |
private const int MOUSEEVENTF_LEFTDOWN = 0x02; | |
private const int MOUSEEVENTF_LEFTUP = 0x04; | |
private const int MOUSEEVENTF_RIGHTDOWN = 0x08; | |
private const int MOUSEEVENTF_RIGHTUP = 0x10; | |
private Cursor Cursor; | |
public VirtualMouse() | |
{ | |
this.Cursor = new Cursor(Cursor.Current.Handle); | |
} | |
public void Move(int X, int Y) | |
{ | |
Cursor.Position = new Point(X, Y); | |
} | |
public void Click() | |
{ | |
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, (uint)Cursor.Position.X, (uint)Cursor.Position.Y, 0, 0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment