




下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、1 一个鼠标类#region 一个鼠标类 2 /*/ <summary> 3 / Mouse Control 4 / Made by Michael 5 / date 2008-0
2、1-30 6 / </summary> 7 class Mouse 8 9 internal const byte SM_MOUSEPRESENT = 19; 10
3、; internal const byte SM_CMOUSEBUTTONS = 43; 11 internal const byte SM_MOUSEWHEELPRESENT = 75; 12 13 inter
4、nal struct POINTAPI 14 15 internal int x; 16 internal int y;
5、;17 18 19 internal struct RECT 20 21 internal int
6、160;left; 22 internal int top; 23 internal int right; 24 &
7、#160;internal int bottom; 25 26 27 System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SwapMouseButton") 28
8、0; internal extern static int SwapMouseButton(int bSwap); 29 30 System.Runtime.InteropServices.DllImport("user32", EntryPoint = "ClipCursor") 31
9、; internal extern static int ClipCursor(ref RECT lpRect); 32 33 System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = &qu
10、ot;GetCursorPos") 34 internal extern static int GetCursorPos(ref POINTAPI lpPoint); 35 36 System.Runtime.InteropServices.DllImport("user32.
11、dll", EntryPoint = "ShowCursor") 37 internal extern static bool ShowCursor(bool bShow); 38 39 System.Runtime.InteropServices.DllImport(&
12、quot;user32.dll", EntryPoint = "EnableWindow") 40 internal extern static int EnableWindow(int hwnd, int fEnable); 41 42 System
13、.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "GetWindowRect") 43 internal extern static int GetWindowRect(int hwnd, ref RECT lpRect); 44
14、60;45 System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetCursorPos") 46 internal extern static int SetCursorPos(int x,
15、160;int y); 47 48 System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "GetSystemMetrics") 49 internal extern static int&
16、#160;GetSystemMetrics(int nIndex); 50 51 System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetDoubleClickTime") 52 internal ext
17、ern static int SetDoubleClickTime(int wCount); 53 54 System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "GetDoubleClickTime") 55
18、160; internal extern static int GetDoubleClickTime(); 56 57 System.Runtime.InteropServices.DllImport("kernel32.DLL", EntryPoint = "Sleep") 58 &
19、#160; internal extern static void Sleep(int dwMilliseconds); 59 60 /得到鼠标相对与全屏的坐标,不是相对与你的Form的,且与你的分辨率有关系 61 62 public static int
20、FullScreenPosition_X 63 64 get 65 66
21、; POINTAPI _POINTAPI = new POINTAPI(); 67 68 GetCursorPos(ref _POINTAPI); 69 70
22、0; return _POINTAPI.x; 71 72 73 74 public
23、160;static int FullScreenPosition_Y 75 76 get 77 78
24、0; POINTAPI _POINTAPI = new POINTAPI(); 79 80 GetCursorPos(ref _POINTAPI); 81 82
25、60; return _POINTAPI.y; 83 84 85 86 &
26、#160; /隐藏 显示 鼠标 87 public static void Hide() 88 89 ShowCursor(false);
27、160;90 91 92 public static void Show() 93 94 ShowCu
28、rsor(true); 95 96 97 /将鼠标锁定在你的Form里 不过你得将你的Form先锁了,Form Resize 就失效了 98 public
29、0;static void Lock(System.Windows.Forms.Form ObjectForm) 99 100 RECT _FormRect = new RECT();101102
30、160; GetWindowRect(ObjectForm.Handle.ToInt32(), ref _FormRect);103104 ClipCursor(ref _FormRect);105 106107
31、160; public static void UnLock()108 109 RECT _ScreenRect = new RECT();110111
32、 _ScreenRect.top = 0;112 _ScreenRect.left = 0;113 _ScreenRect.bottom = System.Windows.Forms.Screen.
33、PrimaryScreen.WorkingArea.Bottom;114 _ScreenRect.right = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Right;115116 ClipCursor(ref
34、0; _ScreenRect);117 118119 /鼠标失效,不过失效的好像不只是鼠标,小心哦 120 public static void Disable(System.Windows.Forms.Form ObjectForm)121
35、160; 122 EnableWindow(ObjectForm.Handle.ToInt32(), 0);123 124125 public static void
36、160;Enable(System.Windows.Forms.Form ObjectForm)126 127 EnableWindow(ObjectForm.Handle.ToInt32(), 1);128 129
37、; / 得到你的鼠标类型 130 public static string Type131 132 get133 &
38、#160; 134 if (GetSystemMetrics(SM_MOUSEPRESENT) = 0)135
39、0; 136 return "本计算机尚未安装鼠标"137 138
40、60; else139 140
41、;if (GetSystemMetrics(SM_MOUSEWHEELPRESENT) != 0)141 142
42、160; return GetSystemMetrics(SM_CMOUSEBUTTONS) + "键滚轮鼠标"143 144
43、0; else145 146
44、 return GetSystemMetrics(SM_CMOUSEBUTTONS) + "键鼠标"147 148
45、0; 149 150 151152 / 设置鼠标双击时间153 public static void DoubleClickTime_Set(int MouseDoubleClickTime)154 155
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2023年度会计硕士练习题附参考答案详解【培优】
- 美容化妆人员经典例题附答案详解【培优B卷】
- 应急出口培训课件
- 2025年收银审核员考前冲刺试卷含答案详解(培优B卷)
- 2025年高校教师资格证之《高等教育法规》考试题库及1套完整答案详解
- 防晒与皮肤癌预防
- 2024-2025学年度注册电气工程师试题附答案详解【综合卷】
- 旅行中传染病风险评估与防护护理指南
- 《就业指导与实训学习指导与练习》参考答案
- 2025年包头市东河区机关所属事业单位春季引进51名高层次和紧缺急需人才笔试高频难、易错点备考题库及参考答案详解1套
- 煤矿安全规程2025版解读
- 尿培养的采集
- 具有法律效应的还款协议书6篇
- 东航空乘英语考试题目及答案
- 2025绿植租赁协议(简易版)
- T-AOPA0062-2024电动航空器电推进系统动力电机控制器技术规范
- 《三级工学一体化师资培训》课件-第四课:教学活动策划
- 2025年全国企业员工全面质量管理知识竞赛题及参考答案
- 2025年秋季开学典礼诗歌朗诵稿:纪念抗战胜利八十周年
- 2025年广东省中考英语试卷深度评析及2026年备考策略
- 适老化家装设计
评论
0/150
提交评论