WinMenuSelectItem,A,, will only act upon the Active Window, so whatever program has focus.
Everything does not instantaneously come into focus when you click on the window. It takes Microsoft Windows time to process this. Therefor any action you take on the Active Window will be the wrong window.
You can fix this by either adding a short
Sleep in your hotkey function, or by using the
MouseGetPos to capture the application window under the cursor and pass that to the WinMenuSelectItem command instead. You can do this at the same time you're detecting the mouse is over the EVERYTHING_CLOSE_BUTTON1 control.
Code: Select all
#IfWinActive ahk_class EVERYTHING
~MButton::
Sleep, 100
WinMenuSelectItem,A,,Help,About
Return
#IfWinActive ; EVERYTHING
Code: Select all
#IfWinActive ahk_class EVERYTHING
~MButton::
MouseGetPos,,, hwnd, ctrl
if (ctrl == "EVERYTHING_CLOSE_BUTTON1")
WinMenuSelectItem,ahk_id %hwnd%,,Help,About
Return
#IfWinActive ; EVERYTHING
Going forward, please wrap all your hotkeys inside of functions to protect their variable scope from global mish-mashing.
If you're using Everything v1.5a, then the ahk_class is
EVERYTHING_(1.5a) for #IfWinActive.
Code: Select all
#IfWinActive ahk_class EVERYTHING_(1.5a)
~MButton::
hotkey_everything_mclick_search()
{
Keywait,MButton
MouseGetPos,,, hwnd, ctrl
if (ctrl == "EVERYTHING_CLOSE_BUTTON1")
{
WinMenuSelectItem,ahk_id %hwnd%,,History,Home
; more stuff...
}
}
#IfWinActive ; EVERYTHING