我希望鼠标右键在DOWN上发送单个键,在UP上发出另一个单独,单个键击。
“伪代码”示例,其中按下鼠标右键通过发送其热键(i)切换吸管工具,然后释放鼠标右键发送刷子热键(b):
RButton down::
Send i ; Send eyedropper hotkey
RButton up::
Send b ; Send brush hotkey
我从其他问题中了解到,使用GetKeyState的while循环可以在那里获得部分,但是while循环会导致密钥快速激活,这是不可取的。
如何让鼠标右键在上/下只发送一次相应的上/下热键?
答案 0 :(得分:0)
; RIGHT BUTTON HOTKEY
RButton::
GetKeyState, state, RButton, P ;GET RIGHT MOUSE BUTTON STATE
if state = D ;IF BUTTON STATE = DOWN
{
SetTimer, CheckRButtonState, 10 ;SET TIMER TO MONITOR WHEN IT WAS RELEASED
Goto, RButtonDown ;JUMP TO SUBROUTINE FOR BUTTON STATE = DOWN
}
return
; TIMER
CheckRButtonState: ;TRIGGERED BY TIMER IN EVERY 10 MILLISECONDS
GetKeyState, state, RButton, P ;GET RIGHT MOUSE BUTTON STATE
if state = U ;IF BUTTON STATE = UP
{
SetTimer, CheckRButtonState, Off ;STOP TIMER
Goto, RButtonUp ;JUMP TO SUBROUTINE FOR BUTTON STATE = UP
}
return
; SUBROUTINE FOR RIGHT BUTTON PRESSED
RButtonDown:
TrayTip,Down, %state% ;PUT HERE THE TASKS YOU WANT IT TO PERFORM WHEN BUTTON IS DOWN
return
; SUBROUTINE FOR RIGHT BUTTON RELEASED
RButtonUp:
TrayTip,Up, %state% ;PUT HERE THE TASKS YOU WANT IT TO PERFORM WHEN BUTTON IS UP
return