Restoring Alt+Tab functionality after remapping the Alt key

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
PatMk
Posts: 5
Joined: 23 Apr 2021, 06:59

Restoring Alt+Tab functionality after remapping the Alt key

Post by PatMk » 23 Jan 2022, 11:16

Hi,

I'd like to restore the Window's Alt+Tab functionality that I broke by remapping the LAlt key to a virtual F22 key for other purposes.

I've tried the "AltTab" hotkeys but wasn't able to get the desired result: https://www.autohotkey.com/docs/Hotkeys.htm#alttab

My current code:

Code: Select all

LAlt::F22
F22 & Tab::
    Send {LAlt Down}{Tab}          
    KeyWait, F22  ; Wait to release F22 key
    Send {LAlt Up} ; Close switcher on hotkey release
return
It opens the switcher and keeps it open until I release the F22(LAlt) key, but I'm unable to press Tab (or Shift+Tab) to move between the windows. Because when I press Tab again, it also sends F22 key (I keep it pressed).

If my explanation doesn't make sense, the desired outcome should: I just want to get back the full Alt+Tab functionality using the LAlt(F22)+Tab keys, without removing this LAlt::F22 remapping.

Thank you.

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: Restoring Alt+Tab functionality after remapping the Alt key

Post by amateur+ » 23 Jan 2022, 11:26

Code: Select all

#InputLevel 1 
LAlt::F22
#InputLevel 0
F22 & Tab::AltTab
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

User avatar
mikeyww
Posts: 26934
Joined: 09 Sep 2014, 18:38

Re: Restoring Alt+Tab functionality after remapping the Alt key

Post by mikeyww » 23 Jan 2022, 11:32

Possibly another one:

Code: Select all

LAlt::F22     ; Triggers on release
<!Tab::AltTab

PatMk
Posts: 5
Joined: 23 Apr 2021, 06:59

Re: Restoring Alt+Tab functionality after remapping the Alt key

Post by PatMk » 23 Jan 2022, 12:16

Thank you for the answers.
amateur+ wrote:
23 Jan 2022, 11:26

Code: Select all

#InputLevel 1 
LAlt::F22
#InputLevel 0
F22 & Tab::AltTab
The problem with this solution is that Alt stays pressed after the window is switched. Any idea how to overcome it?
mikeyww wrote:
23 Jan 2022, 11:32
Possibly another one:

Code: Select all

LAlt::F22     ; Triggers on release
<!Tab::AltTab
This solution works on its own but breaks my other shortcuts associated with this F22 key.
An example of other shortcu that stops working:

Code: Select all

F22 & k::Send, {Blind}{Left}
Any ideas on how to fix this?

User avatar
mikeyww
Posts: 26934
Joined: 09 Sep 2014, 18:38

Re: Restoring Alt+Tab functionality after remapping the Alt key

Post by mikeyww » 23 Jan 2022, 13:00

Code: Select all

LAlt::F22     ; Triggers on release
<!Tab::AltTab
<!k::Send x

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: Restoring Alt+Tab functionality after remapping the Alt key

Post by amateur+ » 23 Jan 2022, 13:00

Code: Select all

SetTimer, Alt_check, 100
LAlt::F22
LAlt & Tab::AltTab  ; But I think mikeyww's <!Tab::AltTab should be better.

Alt_check:
ToolTip, % "LAlt physical state:`t" . GetKeyState("LAlt", "P") . "`nLAlt logical state:`t`t" . GetKeyState("LAlt") 
		. "`nF22 physical state:`t`t" . GetKeyState("F22", "P") . "`nF22 logical state:`t`t" . GetKeyState("F22") 
return
Last edited by amateur+ on 23 Jan 2022, 13:03, edited 1 time in total.
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

User avatar
mikeyww
Posts: 26934
Joined: 09 Sep 2014, 18:38

Re: Restoring Alt+Tab functionality after remapping the Alt key

Post by mikeyww » 23 Jan 2022, 13:03

This worked as well (I tested with F3).

Code: Select all

F3::F3
LAlt::F3     ; Triggers on release
<!Tab::AltTab
F3 & k::Send x

Post Reply

Return to “Ask for Help (v1)”