Alt-tab in Win 10?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Giantrobo
Posts: 1
Joined: 27 Oct 2021, 15:06

Alt-tab in Win 10?

Post by Giantrobo » 27 Oct 2021, 15:28

Hey folks,

I've used AHK a little bit but am really a newbie when it comes to scripts, etc.

I'm trying to map alt-tab to a hotkey (ESC.) Normally alt-tab toggles between locally installed programs just fine... However I can't get it to work on the new Windows-style apps, which don't use a traditional program installation. For example, OneNote 365. Just doesn't work for them. I can press physical keys on the keyboard, but can't seem to get AHK commands to be recognized. Sending an {AltD} command, etc. isn't recognized.

I discovered the Alt-Tab hotkeys, which work great using the mouse wheel example: https://www.autohotkey.com/docs/Hotkeys.htm#alttab

However, when I try to map them to actual function keys, they don't work... I can press individual function keys to execute the hotkey, but can't get them to run in a script.

One other favor: what I really want is to toggle between the last two active windows. The AHK alt-tab hotkeys let me move forward and backward between programs, but when I use alt-tab on my keyboard, it toggles between the two active windows I just worked in. Is there a way to do this in AHK? :headwall:

Here's what I tried:

Code: Select all

;Onenote uses ESC - remap ESC to F4

ESC::F4

F6::AltTabMenu
F7::AltTab
F10::AltTabMenuDismiss

F4::Send {F6}{F7}{F10}
Thanks!
Laszlo
User avatar
mikeyww
Posts: 26602
Joined: 09 Sep 2014, 18:38

Re: Alt-tab in Win 10?

Post by mikeyww » 27 Oct 2021, 15:42

Code: Select all

F3::Send !{Tab}
Rohwedder
Posts: 7555
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Alt-tab in Win 10?

Post by Rohwedder » 28 Oct 2021, 02:51

Hallo,
or:

Code: Select all

Esc::!Tab
Philister
Posts: 33
Joined: 01 Apr 2016, 07:31

Re: Alt-tab in Win 10?

Post by Philister » 12 Nov 2023, 14:19

Not sure where to post this so I'm dumping it in this thread, which seems to be the most recent Alt-Tab related question.

I've chanced upon this solution through a bit of trial and error. It may be superior to actually using !{Tab}, which I recall wasn't always working 100% reliably plus it causes substantial 'GUI flashing' on the screen. On my system, the solution below works very reliably and hardly produces any artifacts / flashing, though that may depend on hardware.
This approach uses Alt-Escape to get at the HWND of the last active window and stores it, then undoes the effect of Alt-Escape on window order (the window active before was sent to the bottom of the pile). It then activates the window whose handle was retrieved a second time. Here goes:

Code: Select all

Send, !{Escape}
Sleep, 1
LastWin := WinExist("A")
Send, +!{Escape}
Sleep, 1
WinActivate, ahk_id %LastWin%
Post Reply

Return to “Ask for Help (v1)”