本帖最后由 yu2n 于 2015-4-18 20:47 编辑
'VBS 设置鼠标指针精确度(5秒内) By yu2n
'Win7 x64 测试通过- 'VBS 设置鼠标指针精确度(5秒内) By yu2n
- 'Win7 x64 测试通过
- Const sTitle = "鼠标 属性" ' 查找窗口名称
- Const nTimeOut = 5 ' 指定超时时间
-
- Dim wso
- Set wso = CreateObject("WScript.Shell")
-
- ' 打开鼠标控制面板
- wso.Run "control.exe main.cpl"
-
- Dim dtStart, bFind
- dtStart = Now()
- Do While DateDiff("s", dtStart, Now()) < nTimeOut
- WScript.Sleep 200
- If CreateObject("WScript.Shell").Appactivate(sTitle) Then
- bFind = True ' 做标记-已找到
- Exit Do
- End If
- Loop
-
- If bFind Then
- ' 发送按键
- wso.SendKeys "(^{TAB})"
- WScript.Sleep 200
- wso.SendKeys "(^{TAB})"
- WScript.Sleep 200
- wso.SendKeys "(%E)"
- WScript.Sleep 200
- wso.SendKeys "(%A)"
- WScript.Sleep 1500
- wso.SendKeys "{ESC}"
- WScript.Sleep 200
- wso.Popup "完成!耗时 " & DateDiff("s", dtStart, Now()) _
- & " 秒。" & String(3,vbTab), 3, WScript.ScriptName, vbSystemModal+vbInformation
- Else
- wso.Popup "无法打开[" & sTitle & "]选项卡!耗时 " & DateDiff("s", dtStart, Now()) _
- & " 秒。" & String(3,vbTab), 3, WScript.ScriptName, vbSystemModal+vbCritical
- End If
复制代码
|