我做了 Ctrl + Shift + X 使用AutoIt启动一个函数,但是使用 Ctrl 和 Shift 键被卡住了。插入{CTRL up}
和{SHIFT up}
无效。为什么会这样?
我的AutoIt脚本:
$dll = DllOpen("C:\Windows\System32\user32.dll")
Global Const $keys[8] = [0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0x5b, 0x5c]
;0xa0 LSHIFT
;0xa1 RSHIFT
;0xa2 LCTRL
;0xa3 RCTRL
;0xa4 LALT
;0xa5 RALT
;0x5b LWIN
;0x5c RWIN
HotKeySet("{PAUSE}", "stop")
HotKeySet("^X", test)
Opt("SendKeyDelay", 0)
Opt("SendKeyDownDelay", 0)
While True
Sleep(500)
WEnd
Func test()
Send("The control and shift keys are going to be stuck down at the end of this.")
Send("{ENTER}")
Send("{ENTER}")
Send("PlaceHolder,")
Send("{ENTER}")
Send("PlaceHolder")
Send("{TAB}")
Send("{HOME}")
Send("{LCTRL up}")
Send("{RCTRL up}")
Send("{LSHIFT up}")
Send("{RSHIFT up}")
Call("UnstickKeys")
EndFunc
Func UnstickKeys()
For $vkvalue In $keys
DllCall($dll, "int", "keybd_event", "int", $vkvalue, "int", 0, "long", 2, "long", 0) ;Release each key
Next
EndFunc
Func stop()
Exit
EndFunc ;==>stop the script
答案 0 :(得分:2)
我在下面修改了你的测试功能。这个解决方案有一个问题,因为要再次运行该功能,你需要放开shift和ctrl并重新压缩它们。您可以从代码中删除dll调用。我还在调用函数时禁用了^ X热键。这样更安全。
Func test()
Hotkeyset("^X")
Send("The control and shift keys are going to be stuck down at the end of this.")
Send("{ENTER}")
Send("{ENTER}")
Send("PlaceHolder,")
Send("{ENTER}")
Send("PlaceHolder")
Send("{TAB}")
Send("{HOME}")
send("{CTRLDOWN}")
send("{CTRLUP}")
send("{SHIFTDOWN}")
send("{SHIFTUP}")
Hotkeyset("^X", "test")
EndFunc