




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
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的,且與你的分辨率有關(guān)系 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 / 設(shè)置鼠標雙擊時間153 public static void DoubleClickTime_Set(int MouseDoubleClickTime)154 155
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度物流信息承運合同模板
- 二零二五年度承攬合同中增值稅稅率變動應(yīng)對策略
- 二零二五年度交通事故人傷賠償公益援助協(xié)議
- 二零二五年度農(nóng)村宅基地租賃協(xié)議(現(xiàn)代農(nóng)業(yè)科技示范園)
- 2025年度新能源汽車抵押貸款服務(wù)合同
- 二零二五年度企業(yè)自然人委托經(jīng)營管理合作協(xié)議
- 二零二五年度在線游戲運營免責協(xié)議書
- 2025年度高校與用人單位就業(yè)質(zhì)量監(jiān)控合作協(xié)議
- 2025年度旅游景區(qū)特色商鋪租賃合同
- 二零二五年度挖機租賃市場拓展與品牌合作協(xié)議
- 2024年新年新氣象
- 2024年度天津市高校大學《輔導員》招聘試題(含答案)
- 工廠布局和物料路徑(英文版)
- 低壓電器基礎(chǔ)-固態(tài)繼電器(電氣控制課件)
- 高三二輪復(fù)習備考指導意見
- 港口散裝液體危險化學品港口經(jīng)營人的裝卸管理人員從業(yè)資格考試
- 2023年四川省公務(wù)員考試行測真題及答案解析
- 日本商務(wù)禮儀課件
- 公務(wù)用車申請表
- 中國民間傳說:田螺姑娘
- 分層過程審核(LPA)檢查表
評論
0/150
提交評論