Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class MouseUtilities
- {
- // import the necessary API function so .NET can
- // marshall parameters appropriately
- [DllImport("user32.dll")]
- static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
- // constants for the mouse_input() API function
- private const int MOUSEEVENTF_MOVE = 0x0001;
- private const int MOUSEEVENTF_ABSOLUTE = 0x8000;
- // simulates movement of the mouse. parameters specify changes
- // in relative position. positive values indicate movement
- // right or down
- public static void Move(int xDelta, int yDelta)
- {
- mouse_event(MOUSEEVENTF_MOVE, xDelta, yDelta, 0, 0);
- }
- // simulates movement of the mouse. parameters specify an
- // absolute location, with the top left corner being the
- // origin
- public static void MoveTo(int x, int y)
- {
- mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, x, y, 0, 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement