Send Alt+Tab behaves differently on W7 and W10

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
JoeWinograd
Posts: 2200
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Send Alt+Tab behaves differently on W7 and W10

26 Jun 2019, 17:11

AHK 1.1.30.03 U32

Wrote a simple script to send Alt+Tab via F12:

Code: Select all

F12::
Send !{Tab}
Return
Works fine on W10 v1809 Pro 64-bit. Fails on W7 Pro SP1 64-bit. However, this works on W7:

Code: Select all

F12::
Send !{Tab}
Sleep 50
Send !{Tab}
Return
Can someone explain what's going on? Yes, I could put in a test of A_OSVersion, but I'd like to understand why the second Alt+Tab is needed in W7. Btw, I get the same results with SendMode Input. Thanks much, Joe
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Send Alt+Tab behaves differently on W7 and W10

26 Jun 2019, 17:22

Both don't work for me.
Win 8.1 64bit

I have to do something like this to Alt-Tab

Code: Select all


*Numpad1::
	run C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Window Switcher.lnk
	sleep,100
	send,{enter}
	Return
User avatar
JoeWinograd
Posts: 2200
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Send Alt+Tab behaves differently on W7 and W10

26 Jun 2019, 17:51

Ran your script on my W7 system...didn't behave like an Alt+Tab...seemed to skew all windows in an angled, tiled fashion in the center of the screen...very strange. Also tried it on my W10 system...rearranged all windows into smaller, non-overlapping windows. Not as weird as W7, but definitely not an Alt+Tab.
GEV
Posts: 1002
Joined: 25 Feb 2014, 00:50

Re: Send Alt+Tab behaves differently on W7 and W10

26 Jun 2019, 18:13

As far as I remember, the AltTab menu on Win7 includes the show-the-desktop option. Maybe that makes the difference.

BTW I'm using this:

Code: Select all

F12:: AltTab()

AltTab(){
    list := ""
    WinGet, id, list
    Loop, %id%
    {
        this_ID := id%A_Index%
        IfWinActive, ahk_id %this_ID%
            continue    
        WinGetTitle, title, ahk_id %this_ID%
        If (title = "")
            continue
        If (!IsWindow(WinExist("ahk_id" . this_ID))) 
            continue
        WinActivate, ahk_id %this_ID%, ,2
            break
    }
}

; This checks if a window is, in fact a window:
IsWindow(hwnd){
	WinGet, s, Style, ahk_id %hwnd% 
   return s & 0xC00000 ? (s & 0x100 ? 0 : 1) : 0
} 
So you don't have to see that quick pop-up of all the apps if you want to switch to the previous active window
Last edited by GEV on 30 Jun 2019, 13:54, edited 4 times in total.
User avatar
JoeWinograd
Posts: 2200
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Send Alt+Tab behaves differently on W7 and W10

26 Jun 2019, 18:35

Hi GEV,
I tried it. Works perfectly in W7; does not work in W10. In W10, it takes the focus off the active window, but does not make the previous one active. Based on the taskbar display, it seems that no window is active. Regards, Joe
GEV
Posts: 1002
Joined: 25 Feb 2014, 00:50

Re: Send Alt+Tab behaves differently on W7 and W10

26 Jun 2019, 18:57

I added another function to it to check whether the windows in the list are proper windows.
User avatar
JoeWinograd
Posts: 2200
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Send Alt+Tab behaves differently on W7 and W10

26 Jun 2019, 19:18

Ah, well-done! Works perfectly in both W7 and W10. Btw, you're missing a closing brace on the AltTab function. Thanks much, Joe

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: OrangeCat and 300 guests