LButton Hotkey seems to prevent Send, {LButton}

丶灬走出姿态 提交于 2019-12-08 04:26:58

问题


I'm at a loss here. As soon as I add the LButton hotkey, the Send, {LButton} doesn't seem to work, but they show up in recently executed lines.

Env. Windows 7x64, Disabled Touchpad, AHK v1.1.31.01.

I try to emulate the Wink application (from DebugMode) to capture screenshots for training purposes. For that reason, I want to capture a screenshot just before a mouse click. This looks easy, and I even vaguely remember doing similar mouse hotkeys in the past. However I can't get this to work.

Step 1: I just reduced it to this simple script:

#InstallKeybdHook
#InstallMouseHook
#UseHook
#Persistent
Return

a::
  Send, {LButton}
Return

q::
ExitApp

When using this script, I can simulate clicking the Left Mouse Button through the a key. Nothing special. However as soon as I add either a line with "Hotkey, $LButton, MySendClick", or "$LButton::" the previously working a hotkey no longer works. In the recently executed lines, you can see the "Send, {LButton}" lines, but nothing is being send. Unexpectedly, the a hotkey actually causes the "$LButton::" hotkey to trigger (without it sending {LButton}). When I change the a hotkey to send "RButton" and the $LButton:: to $RButton::, then Send {Click} works perfectly (eventhough the a hotkey should never be able to trigger $RButton::).

Originally I just wanted to have the following HotKey:

$LButton::
  SoundBeep, 300, 150  ; For testing only
  ; Send, ^{PrintScreen} ; To trigger Greenshot in the background
  Sleep, 100
  Send, {LButton}
Return

I upgraded from AHK v1.1.22.04 to v1.1.31.01. No improvement.

I tried "Click", "sendInput, {LButton}", "Send {Click}", "MouseClick, Left".

I tried "$LButton::", "vk01sc000::", "Hotkey, $LButton, MyClick".

Is this an issue with my specific Windows 7 configuration or an "undocumented AHK feature"?

#InstallKeybdHook
#InstallMouseHook
#UseHook
#Persistent
Return

a::
  Send, {LButton}
Return

$LButton::
  SoundBeep, 300, 150 ; Should be Send, ^{PrintScreen} ; To trigger Greenshot in the background
  MouseClick, Left
Return

q::
ExitApp

In this last test example, When $LButton:: is disabled, the a hotkey works like a charm, but as soon as I enable $LButton::, the a hotkey triggers $LButton:: and no mouse click is being sent to the windows applications.

I would appreciate it when other Windows 7 users could quickly test this issue.


回答1:


In my experience, using keys that you still want the input to pass through need the Tilde prefix.

https://www.autohotkey.com/docs/Hotkeys.htm#Tilde

~LButton::
  SoundBeep, 300, 150 ; Should be Send, ^{PrintScreen} ; To trigger Greenshot in the background
  KeyWait, LButton ; Wait for lbutton to be released.
Return


来源:https://stackoverflow.com/questions/58738870/lbutton-hotkey-seems-to-prevent-send-lbutton

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!