Send Esc right after hotkey routine is over
I'm making code that Send Ctrl (+Shift) + Tab with my mouse button for the purpose of exploring tabs in chrome and other software that support tab. And my hotkey is ~RButton & Wheelup/down. But the problem is, when I release RButton after the hotkeys, it returns context menu and this is bothering me. My first edition of the code is like below.
~RButton & Wheelup:: ;Because of RButton included, it returns context menu
Send, ^+{tab}
return
~RButton & Wheeldown::
Send, ^{tab}
return
And this is the 2nd edition of the code for removing context menu :
~RButton & Wheelup::
Send, ^+{tab}
KeyWait RButton
Send {Esc}
return
~RButton & Wheeldown:: ;Similar to above
...
This code successfully remove context menu but while first edition works smoothly (it returns tab move every Wheelup/down while holding on RButton), second edition returns tab move only once even when I keep scrolling. I think KeyWait command interrupt re-executing tab move hotkey. So I made 3rd edition with external function :
SetTimer RButtonUpCanceler, -1
SetTimer RButtonDownCanceler, -1 ;auto-execute code
~RButton & Wheelup::
Send, ^+{tab}
CtrlTabIndicator := 1 ;Vairable to check if Ctrl Tab is execute recently
SetTimer, CtrlTabExpire, -5000
return
~RButton & Wheeldown:: ;Similar to Wheelup
...
CtrlTabExpire:
CtrlTabIndicator := 0
return
RButtonUpCanceler() { ;Function that remove context menu by sending Esc key
KeyWait RButton, D
KeyWait Wheelup, D
KeyWait RButton
if CtrlTabIndicator
Send {Esc}
SetTimer RButtonUpCanceler, -1
}
RButtonDownCanceler() { ;Similiar to RButtonUpCanceler
...
}
But I don't know exactly why, this code doesn't send Esc and context menu still pop up after ctrl tab hotkeys. I don't care that much which way to solve this problem, but my trial all failed. Anyone can tell me the problem?