Here's what I'm trying to do:
I'm in Program #1 (PDF viewer, SumatraPDF). I hit Alt+Tab. It brings up the thumbnails of all active programs. I click on Microsoft Excel to switch (while continuing to hold Alt key). Excel shows up and then I release the Alt key. This activates the Alt menu shortcuts in Excel. I don't want the alt menu to be activated. I often switch between programs copy / pasting things and I want the focus to remain on the spreadsheet after I release Alt key.
I searched around and found that I was not the only one trying to disable alt menus. I have found some success in being able to disable menu activation if I am already in the program and simply strike and release the alt key. However, none of the below solutions will work in conjunction with the Alt+Tab switch programs with a mouseclick and then release Alt.
FYI I am running Windows 10, latest version of AHK, and Excel 2019 (offline version).
Anyone tackled this problem?
Here's the scripts I've tried...
Option #1:
Code: Select all
~LAlt Up:: return
Code: Select all
Alt::Return ;Disables the key alt when it's pressed alone
Code: Select all
Alt::
KeyWait, Alt
return
LAlt Up::
if (A_PriorKey = "Alt")
return
return
Code: Select all
LAlt::
sendinput, {LAlt down}
sendinput, {SC0E8 down} ;this is the scan code of an unassigned key. As long as you nor the system never use it for anything else, it can be used in THIS way to cancel the menu acceleration.
;tooltip, Lalt is pressed
KeyWait, LAlt
; That line is important, so that ALT does not continuously fire as you are holding it down.
;tooltip, Lalt was released
return
LAlt up::
sendinput, {LAlt up}
sendinput, {SC0E8 up}
;;;Unlike my 2nd keyboard, this method does not use the scan code as a strict "wrapper."
;;tooltip,
return
RAlt::
sendinput, {RAlt down}
sendinput, {SC0E8 down}
;;tooltip, Ralt is pressed
KeyWait, RAlt
;;tooltip, Ralt was released
return
RAlt up::
sendinput, {RAlt up}
sendinput, {SC0E8 up}
;;tooltip,
return
Code: Select all
~LAlt::
Sendinput {Blind}{sc0E9}
KeyWait, LAlt ; this wasit for the key to be RELEASED. So that it doesn't keep spamming SC0E9 (as seen from an AHK window Key history and script info... window.)
Sendinput {Blind}{sc0EA}
return
~RAlt::
Sendinput {Blind}{sc0E9}
KeyWait, RAlt ; so that it doesn't keep spamming SC0E9
Sendinput {Blind}{sc0EA}
return