【C#学习笔记】鼠标控制
2013-10-08 09:27
302 查看
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#学习笔记】鼠标控制
- IntelliJ IDEA 学习笔记 - 鼠标滚轮控制缩放大小
- (原创)c#学习笔记04--流程控制04--循环01--do循环
- (原创)c#学习笔记04--流程控制01--布尔逻辑03--运算符优先级
- Baxter学习笔记6-鼠标点动控制baxter机械臂--实战篇
- (原创)c#学习笔记04--流程控制02--goto语句
- (原创)c#学习笔记04--流程控制03--分支02--if语句
- (原创)c#学习笔记04--流程控制03--分支01--三元运算符
- (原创)c#学习笔记04--流程控制04--循环03--for循环
- Python学习笔记(十七)——用GUI自动化控制键盘鼠标
- 20171012学习笔记Selenium 2 第四章WebDriver API 4.2控制浏览器 4.3简单元素操作4.4鼠标事件4.5键盘事件
- (原创)c#学习笔记04--流程控制04--循环04--循环中断和无限循环
- Java学习笔记 Java调用Win32 API控制鼠标活动范围
- [学习笔记]Asp.net(C#)菜鸟进级系列之流程控制
- C#学习之路,学习笔记 第四章 流程控制
- C#学习笔记 控制流
- (原创)c#学习笔记04--流程控制04--循环02--while循环
- 用C#控制TQ2440开发板上的LED小灯(C# GPIO学习笔记)
- (原创)c#学习笔记04--流程控制01--布尔逻辑01--布尔赋值运算符
- (原创)c#学习笔记04--流程控制03--分支03--switch语句