C# - Control mouse with C#

By , 12/5/2012
(0 ratings)
You can use this functions to control the mouse using C#.

Author: Kevin Gerndt, translation by Michael List
Translate to VB
[DllImport("user32", EntryPoint = "mouse_event")]
private static extern void mouse_event(UInt32 dwFlags, UInt32 dx, UInt32 dy, UInt32
dwData, IntPtr dwExtraInfo);

public enum mouseKeys : int {
     move = 0x0001,
     leftDown = 0x0002,
     leftUp = 0x0004,
     rightDown = 0x0008,
     rightUp = 0x0010,
     middleDown = 0x0020,
     middleUp = 0x0040,
     wheel = 0x0800
}

private void mouseEvent(mouseKeys key) {
     mouse_event((UInt32)key , 0, 0, 0, new System.IntPtr());
}

private void curserPosition(Point point) {
     Cursor.Position = point;
}
Tagged with control mouse, mouse.

Comments

 

Log in, to comment!