功能键卡住(一直按)



我让Ctrl + Shift + X使用AutoIt启动一个函数,但是使用这个CtrlShift键卡住了。插入{CTRL up}{SHIFT up}没有影响。为什么会发生这种情况?

My AutoIt script:

$dll = DllOpen("C:WindowsSystem32user32.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

我修改了下面的测试函数。这个解决方案有一个问题,因为要再次运行该函数,您将需要放弃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

相关内容

  • 没有找到相关文章

最新更新