public static void PressMouseLeft(int to_x, int to_y, bool absolute) { Mickey mickey = GetMickeys(to_x, to_y, absolute); // 0x0002: Left button down Mouse_Event(0x0002 | 0x8000, mickey.x, mickey.y, 0, 0); // 0x0004: Left button up Mouse_Event(0x0004 | 0x8000, mickey.x, mickey.y, 0, 0); }
public static void MoveMouse(int to_x, int to_y, bool absolute) { int mouseEvent = 0x0001; if (absolute) { mouseEvent |= 0x8000; } Mickey mickey = GetMickeys(to_x, to_y, absolute); // 0x0001 | 0x8000: Move + Absolute position Mouse_Event(mouseEvent, mickey.x, mickey.y, 0, 0); }
static Mickey GetMickeys(int to_x, int to_y, bool absolute) { Mickey mickey = new Mickey(to_x, to_y); if (absolute) { int screenWidth = InternalGetSystemMetrics(0); int screenHeight = InternalGetSystemMetrics(1); // Mickey X coordinate mickey.x = (int)System.Math.Round(to_x * 65536.0 / screenWidth); // Mickey Y coordinate mickey.y = (int)System.Math.Round(to_y * 65536.0 / screenHeight); } return(mickey); }