Make AltTabMenu work more reliably

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
bkej
Posts: 4
Joined: 03 Dec 2019, 06:35

Make AltTabMenu work more reliably

23 Jul 2021, 08:24

Hello,

Code: Select all

RCtrl:: AltTabMenu
is interesting to have the RightControl key display the "Alt Tab menu" without having to hold ALT key.

Problem: when we do RightControl and then click on a window thumbnail (of the Alt Tab menu), then ... behind the scene an ALT key seems to be pressed!
This is noticeable in a Text editor for example: we have to manually do a ALT down and ALT up to remove the pressed ALT.

How to have

Code: Select all

RCtrl:: AltTabMenu
work more reliably, without having to manually do ALT down and ALT up after having clicked on a thumbnail?

Thanks!
User avatar
mikeyww
Posts: 26857
Joined: 09 Sep 2014, 18:38

Re: Make AltTabMenu work more reliably

23 Jul 2021, 09:21

There could be a better way, but the following worked for me.

Code: Select all

RCtrl::AltTabMenu
$!Enter::
!LButton::
last := A_PriorKey, hk := RegExReplace(A_ThisHotkey, "[$!]")
KeyWait, %hk%
Send {Blind}{%hk%}
Send % (last = "RControl" ? "{Alt}" : "") "{Alt up}"
Return
bkej
Posts: 4
Joined: 03 Dec 2019, 06:35

Re: Make AltTabMenu work more reliably

28 Jul 2021, 03:28

mikeyww wrote: There could be a better way, but the following worked for me.
Thanks a lot @mikeyww! Can you explain in a few words how it works?

What does $!Enter:: and !LButton:: with a trailing $ and ! do? Also what does {blind} do in this context?
User avatar
mikeyww
Posts: 26857
Joined: 09 Sep 2014, 18:38

Re: Make AltTabMenu work more reliably

29 Jul 2021, 07:49

I'm not sure that I can explain it well. Reviewing some documentation as well as the script's actual KeyHistory may be informative. The KeyHistory shows you what is happening with the keys. There, you can match the actions with the script. The $ prefix prevents the Send command from triggering the routine again when the routine sends its own hotkey. See the list of modifiers, including ! representing Alt. The blind mode mostly changes how modifier keys are handled. There again, if you examine the key history, you can see the effects with or without the blind mode.

The main idea of the script is to send the hotkey while Alt is up, and then to keep Alt up after that. This is essentially an ad hoc solution, and there may be better ones.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: MiM, ntepa, supplementfacts and 140 guests