public static void RightUp() { PONITAPI location = new PONITAPI(); GetCursorPos(ref location); mouse_event(MOUSEEVENTF_RIGHTUP, location.x, location.y, 0, 0); }
public static void LeftDown() { PONITAPI location = new PONITAPI(); GetCursorPos(ref location); mouse_event(MOUSEEVENTF_LEFTDOWN, location.x, location.y, 0, 0); }
/// <summary> /// 移动鼠标 /// </summary> /// <param name="xDisplacement">横向移动距离(右正左负)</param> /// <param name="yDisplacement">纵向移动距离(下正上负)</param> public static void MoveCursor(int xDisplacement, int yDisplacement) { PONITAPI location = new PONITAPI(); GetCursorPos(ref location); SetCursorPos(location.x + xDisplacement, location.y + yDisplacement); }
/// <summary> /// 左键单击 /// </summary> public static void LeftClick() { PONITAPI location = new PONITAPI(); GetCursorPos(ref location); mouse_event(MOUSEEVENTF_LEFTDOWN, location.x, location.y, 0, 0); Thread.Sleep(100); mouse_event(MOUSEEVENTF_LEFTUP, location.x, location.y, 0, 0); }
public static extern int GetCursorPos(ref PONITAPI p);
private static extern int GetCursorPos(ref PONITAPI p);
private void timer1_Tick(object sender, EventArgs e) { PONITAPI pos = new PONITAPI(); GetCursorPos(ref pos); label2.Text = pos.y+" "+pos.x; }