Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

How can I emulate Alt-Tab function on Win 8 using AHK?


  • Please log in to reply
14 replies to this topic
weekend.ahker
  • Members
  • 3 posts
  • Last active: May 08 2018 12:34 PM
  • Joined: 16 Aug 2010
Hello AHKers,

I recently installed Windows 8 x64 and tried to keep using an AHK script that worked well on Windows 7. Now I got a new problem on Windows 8.

"How can I emulate Alt-Tab function on Win 8 using AHK?"

1. Until Windows 7, "Send, {Alt Down}{Tab}" launched the application-switching window. On Windows 8, it doesn't work.
2. "AltTab" command doesn't work either.

Thank you for your comments and suggestions in advance.

GodlyCheese
  • Members
  • 719 posts
  • Last active: Nov 11 2014 07:12 PM
  • Joined: 30 Aug 2012
You can't. From what I understand Win8 blocks all of AHK's methods to send keystrokes to activate Win8's natural Hotkeys. Don't worry though, we have our top men working on it. Our. Top. MEN! Though this will likely remain an issue for the foreseeable future.

weekend.ahker
  • Members
  • 3 posts
  • Last active: May 08 2018 12:34 PM
  • Joined: 16 Aug 2010
GodlyCheese, thanks for your useful information. Then I look forward to our top men's excellent updates.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
See Alt+tab mapping isn't working anymore in Windows 8.

dericbytes
  • Members
  • 1 posts
  • Last active: Nov 02 2012 05:57 PM
  • Joined: 02 Nov 2012
Work Around - If you just want to toggle between the last program you can use ALT-ESC

Send !{ESC}

squarerootof2
  • Members
  • 1 posts
  • Last active: Apr 01 2014 10:03 PM
  • Joined: 01 Apr 2014

Work Around - If you just want to toggle between the last program you can use ALT-ESC

Send !{ESC}

 

I finally joined this community just to say THANK YOU.  That workaround has made my day a lot easier.  :D



traedoril
  • Members
  • 17 posts
  • Last active: Aug 12 2014 12:21 AM
  • Joined: 18 Jul 2012

Find Window Switcher.lnk in C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch .

Copy the The shortcut to somewhere else (I use documents/ahk).

 

Use this script: 

 

#Tab:: Run, "C:\Users\YourUserNameHere\Documents\ahk\Window Switcher"

 

If you are trying to use the app switcher in SetPoint then I suggest this: 

 

^!*0:: Run, "C:\Users\YourUserNameHere\Documents\ahk\Window Switcher"

 

Then in SetPoint Bind the keystroke for app switcher to Ctrl+Alt+Shift+0



loop
  • Members
  • 1 posts
  • Last active: Sep 12 2014 10:07 PM
  • Joined: 28 Jul 2014

Thanks, traedoril, for the tip on using Window Switcher.lnk.

 

It's the work-around I've been looking for.  I tried using the ALT-ESC method, but unfortunately this only works in one direction and wont toggle back and forth between two windows the same as ALT-TAB will.  Below is the script I use:

 

;;  *****************************************

    GoTo.Last.Window:

;;  *****************************************

               CoordMode, Mouse, Screen

               Sleep, 125 ; 1,000 = 1 second

               run C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Window Switcher.lnk

               Sleep, 100 ; 1,000 = 1 second

               sendinput {return}

               return

 

I call this subroutine in my script every time i need to use ALT-TAB.

 

I know this is an old thread, but the topic is still relevant.  I hope this might help someone else.



b0dhikey
  • Members
  • 44 posts
  • Last active: Nov 06 2015 02:43 AM
  • Joined: 26 Jan 2014

Nice find of that shortcut but AHK is not able to sendinput like tab, enter, or left/right arrow to that popup.

At least in my windows 8.1

No wait nevermind!
I didn't put enough sleep! THANKS FOR THE WORKAROUND!

Here's how i used it to switch to my youtube, press pause/play, and then switch back to the two latest tabs that i am alt tabbing between.

 

 

;SCROLLLOCK = PAUSE/PLAY YOUTUBE NO !ESC

sc0046::
KeyWait, ScrollLock
WinGet, currentwindow,id, a
WinActivate, - YouTube - Google Chrome
SendInput, {space}
WinActivate,ahk_id  %currentwindow%
run, C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Window Switcher.lnk
sleep, 100
SendInput, {tab}
SendInput, {return}


arizonabuckeye
  • Members
  • 49 posts
  • Last active: Jun 03 2015 09:19 PM
  • Joined: 13 Mar 2014

So in my getting to know AHK I didn't know/realize there was an AltTab command so i wrote the following:

 

Send, {Alt Down}
Sleep, %SleepVar%
Send, {Tab}
Sleep, %SleepVar%
Send, {Alt Up}

 

Where %SleepVar% is a variable I use outside Setkeydelay to make sure the operation is acted upon/completed before moving on. Would that get around the Win8 blockage?



b0dhikey
  • Members
  • 44 posts
  • Last active: Nov 06 2015 02:43 AM
  • Joined: 26 Jan 2014

So in my getting to know AHK I didn't know/realize there was an AltTab command so i wrote the following:

 

Send, {Alt Down}
Sleep, %SleepVar%
Send, {Tab}
Sleep, %SleepVar%
Send, {Alt Up}

 

Where %SleepVar% is a variable I use outside Setkeydelay to make sure the operation is acted upon/completed before moving on. Would that get around the Win8 blockage?

 

No, it won't.
Why?
Look up UIaccess in the forums.



b0dhikey
  • Members
  • 44 posts
  • Last active: Nov 06 2015 02:43 AM
  • Joined: 26 Jan 2014

So in my getting to know AHK I didn't know/realize there was an AltTab command so i wrote the following:

 

Send, {Alt Down}
Sleep, %SleepVar%
Send, {Tab}
Sleep, %SleepVar%
Send, {Alt Up}

 

Where %SleepVar% is a variable I use outside Setkeydelay to make sure the operation is acted upon/completed before moving on. Would that get around the Win8 blockage?

 

No, it won't.
Why?
Look up UIaccess in the forums. http://www.autohotke...ative-programs/



vildauget
  • Members
  • 1 posts
  • Last active: Apr 11 2015 07:05 PM
  • Joined: 11 Apr 2015

A take on alt-tab for win8 utilizing above information. This example uses a Xbox360 controller key-combo (joy1+6) - change them throughout the code to change.

 
Joy1::
Joy6::
  If GetKeyState("Joy1")
    If GetKeyState("Joy6")
      run C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Window Switcher.lnk
  If not alttabbing_active
  {
    alttabbing_active := true
    SetTimer, AltTabbing, 10
  }
return
 
AltTabbing:
  If not GetKeyState("Joy1")
    If not GetKeyState("Joy6")
    {
      alttabbing_active := false
      send, {enter}
      SetTimer, AltTabbing, Off
    }
return


rommmcek
  • Members
  • 1 posts
  • Last active: Jun 28 2016 02:34 PM
  • Joined: 05 Apr 2015
LCtrl & z:: ; AltTabMenu

 
state := GetKeyState("Capslock", "T")
if state = 1
 SetCapsLockState, Off  ; CapsLock On blocks Task Switching metro window
 
           Send, !{Tab}   ; prevents displaying inactive Task Switching metro window
   run, Window Switcher.lnk ; must be in script directory otherwise include path 
 WinWait, Task Switching,, 2
KeyWait, Ctrl
Send, {Enter}
 
 if state = 1
  SetCapsLockState, On  ; restores CapsLock State
state =
 
return
 
#IfWinActive, Task Switching
LCtrl & q::Send, {Right}
LCtrl & a::Send, {Left}
See also: http://ahkscript.org...p=44371&e=44371 and: http://ahkscript.org....php?f=6&t=5192
 
bye

diaewad
  • Members
  • 37 posts
  • Last active: May 13 2015 05:31 PM
  • Joined: 18 Dec 2014

Nice find of that shortcut but AHK is not able to sendinput like tab, enter, or left/right arrow to that popup.

At least in my windows 8.1

No wait nevermind!
I didn't put enough sleep! THANKS FOR THE WORKAROUND!

Here's how i used it to switch to my youtube, press pause/play, and then switch back to the two latest tabs that i am alt tabbing between.

 

Why not use COM or ControlSend to do that instead?  You wouldn't even have to activate the window.