【C#学习笔记】鼠标控制

2021-09-11 06:12

阅读:805

标签:window   user   ops   names   ica   win   鼠标   学习笔记   ice    using System; using System.Runtime.InteropServices; using System.Windows.Forms; namespace ConsoleApplication1 { class Program { public struct POINT { public int x, y; } const int MOUSEEVENTF_LEFTDOWN = 0x2; const int MOUSEEVENTF_LEFTUP = 0x4; const int MOUSEEVENTF_RIGHTDOWN = 0x8; const int MOUSEEVENTF_RIGHTUP = 0x10; const int MOUSEEVENTF_MIDDLEDOWN = 0x20; const int MOUSEEVENTF_MIDDLEUP = 0x40; const int MOUSEEVENTF_MOVE = 0x1; [DllImport("user32.dll")] public static extern int GetCursorPos(ref POINT p); [DllImport("user32.dll")] public static extern int SetCursorPos(int x, int y); [DllImport("user32.dll")] public static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo); static void Main(string[] args) { POINT p=new POINT(); GetCursorPos(ref p); Console.WriteLine(p.x + " " + p.y); SetCursorPos(0, 0); mouse_event(MOUSEEVENTF_RIGHTDOWN, p.x, p.y, 0, 0); mouse_event(MOUSEEVENTF_RIGHTUP, p.x, p.y, 0, 0); Console.Read(); } } }  【C#学习笔记】鼠标控制标签:window   user   ops   names   ica   win   鼠标   学习笔记   ice   原文地址:http://www.cnblogs.com/tiandsp/p/7440449.html


评论


亲,登录后才可以留言!