本帖最后由 虎虎虎 于 2012-3-2 07:40 编辑
用在坛子里收集的有关键盘指示灯做了操作提示:
数字键锁定提示正常;操作大写锁定,闪屏闪烁的厉害,不知是什么原因?
代码如下:;~ ***提示键盘指示灯状态****
Global Const $VK_NUMLOCK = 0x90
Global Const $VK_SCROLL = 0x91;这个你也可以检测
Global Const $VK_CAPITAL = 0x14
HotKeySet("{NUMLOCK}", "SNUMLOCK")
HotKeySet("{CAPSLOCK}", "SCAPSLOCK")
While 1
Sleep(150)
WEnd
Func SNUMLOCK()
If _GetKeyState($VK_NUMLOCK) = 1 Then
SplashTextOn("", "数字锁定键:开", 150, 40, @DesktopWidth - 200, @DesktopHeight - 90, 1, "黑体", 10)
Send("{numlock on}")
Sleep(3000)
SplashOff()
Else
SplashTextOn("", "数字锁定键:关", 150, 40, @DesktopWidth - 200, @DesktopHeight - 90, 1, "黑体", 10)
Send("{numlock off}")
Sleep(3000)
SplashOff()
EndIf
EndFunc ;==>SNUMLOCK
Func SCAPSLOCK()
If _GetKeyState($VK_CAPITAL) = 1 Then
SplashTextOn("", "大小写锁定键:开",150, 40, @DesktopWidth - 200, @DesktopHeight - 90, 1, "黑体", 10)
Send("{CapsLock on}")
Sleep(3000)
SplashOff()
Else
SplashTextOn("","大小写锁定键:关", 150, 40, @DesktopWidth - 200, @DesktopHeight - 90, 1, "黑体", 10)
Send("{CapsLock off}")
Sleep(3000)
SplashOff()
EndIf
EndFunc ;==>SCAPSLOCK
Func _GetKeyState($VK_Code)
Local $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_Code)
Return $ret[0]
EndFunc ;==>_GetKeyState
|