0
votes

I'm looking to make the right mouse button send a single keystroke on DOWN, and another separate, single keystroke on UP.

"Pseudo-code" example, where pressing down right mouse button toggles an eyedropper tool by sending its hotkey (i), and releasing right mouse button sends the hotkey for brush (b):

RButton down::
Send i ; Send eyedropper hotkey

RButton up::
Send b ; Send brush hotkey

I understand from other questions asked that a while loop using GetKeyState could get part way there, but the while loop causes the key to fire rapidly, which is not desired.

How do I make the right mouse button send its corresponding up/down hotkey only once on up/down?

1
Its works for me by replace RButton down:: with RButton:: and RButton down give me syntax error - Skycc

1 Answers

0
votes
; 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