Solved Classic Alt Tab (Reincarnation)


dacrone

Well-known member
Guru
VIP
Local time
5:23 AM
Posts
3,393
OS
Windows 11 Pro
UPDATE 08 MAY 2025:

Python was giving me :ffs:massive issues trying to override the Windows Alt+Tab. So, I went another route. Got it working with AutoHotKey instead.

*2 Caveats:


A) I cannot get it to dynamically expand height to show more rows of icons automatically. You can still access them all when cycling through, so i am providing 2 versions. One shows 1 row of icons and the other shows 3 rows of icons by default. There are Square and Round of GUI of each, as well as Light and Dark Modes of Each (see Post 4 for Dark Mode).

B) IF you have your Scaling set to different % on each, you must have that set and THEN launch the ahk for it to respect those settings. If you change scaling, you must kill and relaunch the ahk for it to adhere.

*It runs in the background. Can end task by exiting tray icon.

*Will
Center on Screen that Cursor is currently on.

*You can:
Alt+Tab / Shift+Alt+Tab to cycle as normal and stop on desired selection to open that window


Ctrl+Alt+Tab to make it stay on screen until a selection is made

when in Ctrl+Alt+Tab:



Tab / Right Arrow / Mouse Wheel Scroll DownwardCycle Clockwise
Shift+Tab / Left Arrow / Mouse Wheel Scroll UpwardCycle Counter-Clockwise
Spacebar / Enter / Single Click Mouse Left ButtonLaunch Selected Program / Window
EscHide the GUI Without Selecting Anything

All Light Mode Hottrack EXEs are attached to post as ZIPs

(Dark Mode Exes are attached in posts below as ZIPs)

*IF YOU WANT A CUSTOM COLOR OR TRANSPARENCY SET AND ARE UNSURE OF HOW TO DO SO, YOU CAN REQUEST IN THIS THREAD AND I CAN DO IT*

*IF YOU WANT TO COMPILE THE SCRIPT YOURSELF INSTEAD OF DL THE EXEs, YOU CAN ADD "ALWAYSONTOP" AND "TRANSPARENCY" VIA THE EXAMPLES BELOW*:

AlwaysOnTop - Find this Line and add/remove the RED portion:

Gui, New, +HwndhGui -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window

Single or Double Click to Activate - Find these Lines and edit the RED portions (add +AltSubmit = Normal) (remove +AltSubmit = DoubleClick):
Gui, Add, ListView, x-2 y20 w480 h60 +LV0x3 +LV0x8000 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +BackgroundDEDEDE
if (A_GuiEvent = "Normal") {

Background Color - Find this Section and Edit the RED portions:
Gui, Color, 242424
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y80 w415 h28 vMyLabel cWhite Background242424, Embossed Window
Gui, Add, ListView, x-2 y20 w480 h60 +LV0x3 +Icon +gOnListViewClick +Grid -E0x200 +Background242424

Label Text Color - Find this Line and add the RED portion:
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y80 w415 h28 vMyLabel cWhite Background242424, Embossed Window

Label Text Font and Font Size - Find this Line and add the RED portion:
Gui, Font, s11, Consolas

Transparency - Find this Section and add the RED portion:
;get Hwnd of current GUI
DetectHiddenWindows On
Gui, +LastFound
Gui, Show, w457 h117
WinSet, Transparent, 200 < Adjust this number for more or less Transparency
GUI_Hwnd := WinExist()
;Calculate size of GUI

Example at 200
1746557650205.webp

Original Classic Alt+Tab for Comparison:
1746492212904.webp
_______________________________________________________________________________________________________________________________________________


1746728166256.webp
Code:
;Alt-Tab Reincarnation

#SingleInstance force
ListLines, Off
#KeyHistory 0
Menu, Tray, Click, 1
;Menu, Tray, NoIcon
#NoEnv
AutoTrim, Off
#UseHook
#MaxThreadsPerHotKey 2

SetKeyDelay, 0, 20

SplitPath, A_ScriptName,,,, vScriptNameNoExt
Menu, Tray, Tip, % vScriptNameNoExt

;==================================================

vListVisibleWindows := 1
vListCount := 4

;==================================================

hIcon := DllCall("user32\LoadIcon", Ptr,0, Ptr,32512, Ptr) ;IDI_APPLICATION := 32512
hIconDT := LoadPicture("shell32.dll", "w16 h16 icon35", vType)
hIconDTBig := LoadPicture("shell32.dll", "w32 h32 icon35", vType)

Gui, 2:New, +HwndhGui2 -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, 2:Color, DEDEDE
Gui, 2:Font, s11, Consolas
Gui, 2:Add, ListView, x-2 y20 w480 h60 +LV0x3 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +BackgroundDEDEDE

Gui, New, +HwndhGui -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, Font, s11, Consolas
Gui, Color, DEDEDE
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y80 w415 h28 vMyLabel BackgroundDEDEDE, Embossed Window
Gui, Add, ListView, x-2 y20 w480 h57 +LV0x3 +LV0x8000 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +BackgroundDEDEDE
return
 
;==================================================

GuiClose:
Gui, 2:Hide
ExitApp
return

;==================================================

^!Tab::
vKeepOpen := true
vIndex++
if (vIndex > oHWnd.MaxIndex())
    vIndex := 1
LV_Modify(0, "-Select")
LV_Modify(vIndex, "Select Vis")
goto HandleAltTab

!Tab::
+!Tab::
vKeepOpen := false
vIndex += InStr(A_ThisHotkey, "+") ? -1 : 1

HandleAltTab:
Gui, % hGui2 ":Default"
Gui, % hGui ":Default"

if !DllCall("user32\IsWindowVisible", "Ptr",hGui2)
if !DllCall("user32\IsWindowVisible", "Ptr",hGui)
{
    Hotkey, IfWinActive, % "ahk_id " hGui2
    Hotkey, IfWinActive, % "ahk_id " hGui
    Hotkey, *Esc, DoCancel, On
    LV_Delete(), IL_Destroy(hIL)
    hIL := IL_Create(28, 28, 1)
    LV_SetImageList(hIL)
    vCount := 0, vPrompt := "", oHWnd := {}, oTitle := {}, oHIcon := {}, oHIconBig := {}
    Loop % vListCount
    {
        if (A_Index = vListVisibleWindows)
        {
            DetectHiddenWindows, Off
            WinGet, vWinList, List
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd[vCount] := hWnd
                oTitle[vCount] := vFileName
                oHIcon[vCount] := JEE_WinGetIcon(hWnd, 1)
                oHIconBig[vCount] := JEE_WinGetIcon(hWnd, 1)
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)
                LV_ModifyCol(1, 40)
            }

            DetectHiddenWindows, On
        }

        vDesktopFound := false

        Loop, % oHWnd.MaxIndex()
        {
            if (oTitle[A_Index] = "Desktop")
            {
                vDesktopFound := true
                break
            }
        }

        if !vDesktopFound
        {
            vCount += 1
            oHWnd[vCount] := "Desktop"
            oTitle[vCount] := "Desktop"
            oHIcon[vCount] := hIconDT
            oHIconBig[vCount] := hIconDTBig
            IL_Add(hIL, "HICON:*" oHIcon[vCount])
            LV_Add("Icon" vCount)
        }

        if (A_Index = vListIntExpTabs)
        {
            WinGet, vWinList, List, ahk_class TabThumbnailWindow
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd.Push(hWnd)
                oTitle.Push(vFileName)
                oHIcon.Push(JEE_WinGetIcon(hWnd, 1))
                oHIconBig.Push(JEE_WinGetIcon(hWnd, 1))
                ToolTip, % "Title: " oTitle[vCount] " | Icon Index: " vCount
                Sleep, 500
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)
                LV_ModifyCol(1, 40)
            }

        }
    }

    ;Loop 2
    ;    LV_Add("Icon0", "")
    ;==============================
    vIndex := 2
    SetTimer, CheckAlt, 5
    SetTimer, HandleAltTab, 10

;---------GET CENTER OF CURRENT MONITOR---------
        ;get current monitor index
        CurrentMonitorIndex:=GetCurrentMonitorIndex()
        ;get Hwnd of current GUI
        DetectHiddenWindows On
        Gui, 2:Show, w457 H117
        Gui, +LastFound
        WinSet, TransColor, F0F0F0
        Gui, Show, w457 h117
        GUI_Hwnd := WinExist()
        ;Calculate size of GUI
        GetClientSize(GUI_Hwnd,GUI_Width,GUI_Height)
        DetectHiddenWindows Off
        ;Calculate where the GUI should be positioned
        GUI_X:=CoordXCenterScreen(GUI_Width,CurrentMonitorIndex)
        GUI_Y:=CoordYCenterScreen(GUI_Height,CurrentMonitorIndex)

        ;------- / GET CENTER OF CURRENT MONITOR---------
        ;SHOW GUI AT CENTER OF CURRENT SCREEN
        Gui, 2:Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Gui, Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Return

        GetCurrentMonitorIndex(){
        CoordMode, Mouse, Screen
        MouseGetPos, mx, my
        SysGet, monitorsCount, 80

        Loop %monitorsCount%{
            SysGet, monitor, Monitor, %A_Index%
            if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
                Return A_Index
                }
            }
            Return 1
    }

        CoordXCenterScreen(WidthOfGUI,ScreenNumber)
    {
        SysGet, Mon1, Monitor, %ScreenNumber%
        return (( Mon1Right-Mon1Left - WidthOfGUI ) / 2) + Mon1Left
    }

    CoordYCenterScreen(HeightofGUI,ScreenNumber){
        SysGet, Mon1, Monitor, %ScreenNumber%
        return ((Mon1Bottom-Mon1Top - 30 - HeightofGUI ) / 2) + Mon1Top
    }

    GetClientSize(hwnd, ByRef w, ByRef h)
    {
        VarSetCapacity(rc, 16)
        DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
        w := NumGet(rc, 8, "int")
        h := NumGet(rc, 12, "int")
    }
}

if (vIndex < 1)
    vIndex := vCount
if (vIndex > vCount)
    vIndex := 1

ControlSetText,, % oTitle[vIndex], % "ahk_id " hStc
SendMessage, 0x170, % oHIcon[vIndex], 0,, % "ahk_id " hStcImg ;STM_SETICON := 0x170

LV_Modify(0, "-Select")
LV_Modify(vIndex, "Vis")
LV_Modify(vIndex, "Select Vis")
return

;==================================================

CheckAlt:
if !GetKeyState("Alt", "P") && !vKeepOpen
{
    SetTimer, CheckAlt, Off
    SetTimer, HandleAltTab, Off
    if WinExist("ahk_id " hGui) {
        WinHide, ahk_id %hGui%
        if WinExist("ahk_id " hGui2)
            WinHide, ahk_id %hGui2%
    }
    DetectHiddenWindows, On
    if (oTitle[vIndex] = "Desktop")
    {
        DllCall("user32\ShowWindow", "Ptr", hGui2, "Int", 0)
        DllCall("user32\ShowWindow", "Ptr", hGui, "Int", 0)
        WinMinimizeAll
    }
    else
    {
        WinActivate, % "ahk_id " oHWnd[vIndex]
    }
}
return

;==================================================

#If WinActive("ahk_id " hGui2)
#If WinActive("ahk_id " hGui)

Tab::
Right::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

+Tab::
Left::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelUp::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelDown::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

Enter::
NumpadEnter::
Space::
    if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
        WinActivate, % "ahk_id " oHWnd[vIndex]
        vKeepOpen := false
        SetTimer, HandleAltTab, Off
        Gui, 2:Hide
        Gui, Hide
    }
return

Esc::
    vKeepOpen := false
    SetTimer, HandleAltTab, Off
    LV_Modify(0, "-Select")
    vIndex := 0
    Gui, 2:Hide
    Gui, Hide
return
#If

;==================================================

OnListViewClick:
    if (A_GuiEvent = "Normal") {
        LV_GetText(vSelectedTitle, A_EventInfo, 1)
        vIndex := A_EventInfo
        if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
            WinActivate, % "ahk_id " oHWnd[vIndex]
            vKeepOpen := false
            SetTimer, HandleAltTab, Off
            Gui, 2:Hide
            Gui, Hide
        }
    }
return

;==================================================

DoCancel:
SetTimer, CheckAlt, Off
Hotkey, IfWinActive, % "ahk_id " hGui2
Hotkey, IfWinActive, % "ahk_id " hGui
Hotkey, *Esc, DoCancel, Off
WinHide, % "ahk_id " hGui2
WinHide, % "ahk_id " hGui
return

;==================================================

JEE_WinGetIcon(hWnd, vDoGetBig:=0)
{
    static vSfx := (A_PtrSize=8) ? "Ptr" : ""
    if !hWnd || !WinExist("ahk_id " hWnd)
        return 0
    if vDoGetBig
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    else
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    return 0
}

;==================================================

JEE_WinHasTaskbarButton(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
    || DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    if DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
        return 0
    return 1
}

;==================================================

JEE_WinHasAltTabIcon(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
    || (vWinStyle & 0x8000000) ;WS_DISABLED := 0x8000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
    || (vWinExStyle & 0x8000000) ;WS_EX_NOACTIVATE := 0x8000000
        return 0
    return 1
}

;==================================================

WinSetRegion(hWnd, Radius := 20)
{
    hRgn := DllCall("gdi32\CreateRoundRectRgn", "Int", 0, "Int", 0, "Int", 457, "Int", 117, "Int", Radius, "Int", Radius, "Ptr")
    DllCall("user32\SetWindowRgn", "Ptr", hWnd, "Ptr", hRgn, "Int", 1)
}


1746722673279.webp
Code:
;Alt-Tab Reincarnation

#SingleInstance force
ListLines, Off
#KeyHistory 0
Menu, Tray, Click, 1
;Menu, Tray, NoIcon
#NoEnv
AutoTrim, Off
#UseHook
#MaxThreadsPerHotKey 2

SetKeyDelay, 0, 20

SplitPath, A_ScriptName,,,, vScriptNameNoExt
Menu, Tray, Tip, % vScriptNameNoExt

;==================================================

vListVisibleWindows := 1
vListCount := 4

;==================================================

hIcon := DllCall("user32\LoadIcon", Ptr,0, Ptr,32512, Ptr) ;IDI_APPLICATION := 32512
hIconDT := LoadPicture("shell32.dll", "w16 h16 icon35", vType)
hIconDTBig := LoadPicture("shell32.dll", "w32 h32 icon35", vType)

Gui, 2:New, +HwndhGui2 -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, 2:Color, DEDEDE
Gui, 2:Font, s11, Consolas
Gui, 2:Add, ListView, x-2 y20 w480 h60 +LV0x3 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +BackgroundDEDEDE

Gui, New, +HwndhGui -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, Font, s11, Consolas
Gui, Color, DEDEDE
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y80 w415 h28 vMyLabel BackgroundDEDEDE, Embossed Window
Gui, Add, ListView, x-2 y20 w480 h57 +LV0x3 +LV0x8000 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +BackgroundDEDEDE
return
 
;==================================================

GuiClose:
Gui, 2:Hide
ExitApp
return

;==================================================

^!Tab::
vKeepOpen := true
vIndex++
if (vIndex > oHWnd.MaxIndex())
    vIndex := 1
LV_Modify(0, "-Select")
LV_Modify(vIndex, "Select Vis")
goto HandleAltTab

!Tab::
+!Tab::
vKeepOpen := false
vIndex += InStr(A_ThisHotkey, "+") ? -1 : 1

HandleAltTab:
Gui, % hGui2 ":Default"
Gui, % hGui ":Default"

if !DllCall("user32\IsWindowVisible", "Ptr",hGui2)
if !DllCall("user32\IsWindowVisible", "Ptr",hGui)
{
    Hotkey, IfWinActive, % "ahk_id " hGui2
    Hotkey, IfWinActive, % "ahk_id " hGui
    Hotkey, *Esc, DoCancel, On
    LV_Delete(), IL_Destroy(hIL)
    hIL := IL_Create(28, 28, 1)
    LV_SetImageList(hIL)
    vCount := 0, vPrompt := "", oHWnd := {}, oTitle := {}, oHIcon := {}, oHIconBig := {}
    Loop % vListCount
    {
        if (A_Index = vListVisibleWindows)
        {
            DetectHiddenWindows, Off
            WinGet, vWinList, List
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd[vCount] := hWnd
                oTitle[vCount] := vFileName
                oHIcon[vCount] := JEE_WinGetIcon(hWnd, 1)
                oHIconBig[vCount] := JEE_WinGetIcon(hWnd, 1)
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)
                LV_ModifyCol(1, 40)
            }

            DetectHiddenWindows, On
        }

        vDesktopFound := false

        Loop, % oHWnd.MaxIndex()
        {
            if (oTitle[A_Index] = "Desktop")
            {
                vDesktopFound := true
                break
            }
        }

        if !vDesktopFound
        {
            vCount += 1
            oHWnd[vCount] := "Desktop"
            oTitle[vCount] := "Desktop"
            oHIcon[vCount] := hIconDT
            oHIconBig[vCount] := hIconDTBig
            IL_Add(hIL, "HICON:*" oHIcon[vCount])
            LV_Add("Icon" vCount)
        }

        if (A_Index = vListIntExpTabs)
        {
            WinGet, vWinList, List, ahk_class TabThumbnailWindow
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd.Push(hWnd)
                oTitle.Push(vFileName)
                oHIcon.Push(JEE_WinGetIcon(hWnd, 1))
                oHIconBig.Push(JEE_WinGetIcon(hWnd, 1))
                ToolTip, % "Title: " oTitle[vCount] " | Icon Index: " vCount
                Sleep, 500
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)
                LV_ModifyCol(1, 40)
            }

        }
    }

    ;Loop 2
    ;    LV_Add("Icon0", "")
    ;==============================
    vIndex := 2
    WinSetRegion(hGui2, 20)
    WinSetRegion(hGui, 20)
    SetTimer, CheckAlt, 5
    SetTimer, HandleAltTab, 10

;---------GET CENTER OF CURRENT MONITOR---------
        ;get current monitor index
        CurrentMonitorIndex:=GetCurrentMonitorIndex()
        ;get Hwnd of current GUI
        DetectHiddenWindows On
        Gui, 2:Show, w457 H117
        Gui, +LastFound
        WinSet, TransColor, F0F0F0
        Gui, Show, w457 h117
        GUI_Hwnd := WinExist()
        ;Calculate size of GUI
        GetClientSize(GUI_Hwnd,GUI_Width,GUI_Height)
        DetectHiddenWindows Off
        ;Calculate where the GUI should be positioned
        GUI_X:=CoordXCenterScreen(GUI_Width,CurrentMonitorIndex)
        GUI_Y:=CoordYCenterScreen(GUI_Height,CurrentMonitorIndex)

        ;------- / GET CENTER OF CURRENT MONITOR---------
        ;SHOW GUI AT CENTER OF CURRENT SCREEN
        Gui, 2:Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Gui, Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Return

        GetCurrentMonitorIndex(){
        CoordMode, Mouse, Screen
        MouseGetPos, mx, my
        SysGet, monitorsCount, 80

        Loop %monitorsCount%{
            SysGet, monitor, Monitor, %A_Index%
            if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
                Return A_Index
                }
            }
            Return 1
    }

        CoordXCenterScreen(WidthOfGUI,ScreenNumber)
    {
        SysGet, Mon1, Monitor, %ScreenNumber%
        return (( Mon1Right-Mon1Left - WidthOfGUI ) / 2) + Mon1Left
    }

    CoordYCenterScreen(HeightofGUI,ScreenNumber){
        SysGet, Mon1, Monitor, %ScreenNumber%
        return ((Mon1Bottom-Mon1Top - 30 - HeightofGUI ) / 2) + Mon1Top
    }

    GetClientSize(hwnd, ByRef w, ByRef h)
    {
        VarSetCapacity(rc, 16)
        DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
        w := NumGet(rc, 8, "int")
        h := NumGet(rc, 12, "int")
    }
}

if (vIndex < 1)
    vIndex := vCount
if (vIndex > vCount)
    vIndex := 1

ControlSetText,, % oTitle[vIndex], % "ahk_id " hStc
SendMessage, 0x170, % oHIcon[vIndex], 0,, % "ahk_id " hStcImg ;STM_SETICON := 0x170

LV_Modify(0, "-Select")
LV_Modify(vIndex, "Vis")
LV_Modify(vIndex, "Select Vis")
return

;==================================================

CheckAlt:
if !GetKeyState("Alt", "P") && !vKeepOpen
{
    SetTimer, CheckAlt, Off
    SetTimer, HandleAltTab, Off
    if WinExist("ahk_id " hGui) {
        WinHide, ahk_id %hGui%
        if WinExist("ahk_id " hGui2)
            WinHide, ahk_id %hGui2%
    }
    DetectHiddenWindows, On
    if (oTitle[vIndex] = "Desktop")
    {
        DllCall("user32\ShowWindow", "Ptr", hGui2, "Int", 0)
        DllCall("user32\ShowWindow", "Ptr", hGui, "Int", 0)
        WinMinimizeAll
    }
    else
    {
        WinActivate, % "ahk_id " oHWnd[vIndex]
    }
}
return

;==================================================

#If WinActive("ahk_id " hGui2)
#If WinActive("ahk_id " hGui)

Tab::
Right::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

+Tab::
Left::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelUp::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelDown::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

Enter::
NumpadEnter::
Space::
    if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
        WinActivate, % "ahk_id " oHWnd[vIndex]
        vKeepOpen := false
        SetTimer, HandleAltTab, Off
        Gui, 2:Hide
        Gui, Hide
    }
return

Esc::
    vKeepOpen := false
    SetTimer, HandleAltTab, Off
    LV_Modify(0, "-Select")
    vIndex := 0
    Gui, 2:Hide
    Gui, Hide
return
#If

;==================================================

OnListViewClick:
    if (A_GuiEvent = "Normal") {
        LV_GetText(vSelectedTitle, A_EventInfo, 1)
        vIndex := A_EventInfo
        if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
            WinActivate, % "ahk_id " oHWnd[vIndex]
            vKeepOpen := false
            SetTimer, HandleAltTab, Off
            Gui, 2:Hide
            Gui, Hide
        }
    }
return

;==================================================

DoCancel:
SetTimer, CheckAlt, Off
Hotkey, IfWinActive, % "ahk_id " hGui2
Hotkey, IfWinActive, % "ahk_id " hGui
Hotkey, *Esc, DoCancel, Off
WinHide, % "ahk_id " hGui2
WinHide, % "ahk_id " hGui
return

;==================================================

JEE_WinGetIcon(hWnd, vDoGetBig:=0)
{
    static vSfx := (A_PtrSize=8) ? "Ptr" : ""
    if !hWnd || !WinExist("ahk_id " hWnd)
        return 0
    if vDoGetBig
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    else
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    return 0
}

;==================================================

JEE_WinHasTaskbarButton(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
    || DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    if DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
        return 0
    return 1
}

;==================================================

JEE_WinHasAltTabIcon(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
    || (vWinStyle & 0x8000000) ;WS_DISABLED := 0x8000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
    || (vWinExStyle & 0x8000000) ;WS_EX_NOACTIVATE := 0x8000000
        return 0
    return 1
}

;==================================================

WinSetRegion(hWnd, Radius := 20)
{
    hRgn := DllCall("gdi32\CreateRoundRectRgn", "Int", 0, "Int", 0, "Int", 457, "Int", 117, "Int", Radius, "Int", Radius, "Ptr")
    DllCall("user32\SetWindowRgn", "Ptr", hWnd, "Ptr", hRgn, "Int", 1)
}


1746728292360.webp

Code:
;Alt-Tab Reincarnation

#SingleInstance force
ListLines, Off
#KeyHistory 0
Menu, Tray, Click, 1
;Menu, Tray, NoIcon
#NoEnv
AutoTrim, Off
#UseHook
#MaxThreadsPerHotKey 2

SetKeyDelay, 0, 20

SplitPath, A_ScriptName,,,, vScriptNameNoExt
Menu, Tray, Tip, % vScriptNameNoExt

;==================================================

vListVisibleWindows := 1
vListCount := 4

;==================================================

hIcon := DllCall("user32\LoadIcon", Ptr,0, Ptr,32512, Ptr) ;IDI_APPLICATION := 32512
hIconDT := LoadPicture("shell32.dll", "w16 h16 icon35", vType)
hIconDTBig := LoadPicture("shell32.dll", "w32 h32 icon35", vType)

Gui, 2:New, +HwndhGui2 -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, 2:Color, DEDEDE
Gui, 2:Font, s11, Consolas
Gui, 2:Add, ListView, x-2 y20 w480 h210 +LV0x3 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +BackgroundDEDEDE

Gui, New, +HwndhGui -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, Font, s11, Consolas
Gui, Color, DEDEDE
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y230 w415 h28 vMyLabel BackgroundDEDEDE, Embossed Window
Gui, Add, ListView, x-2 y20 w480 h210 +LV0x3 +LV0x8000 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +BackgroundDEDEDE
return
 
;==================================================

GuiClose:
Gui, 2:Hide
ExitApp
return

;==================================================

^!Tab::
vKeepOpen := true
vIndex++
if (vIndex > oHWnd.MaxIndex())
    vIndex := 1
LV_Modify(0, "-Select")
LV_Modify(vIndex, "Select Vis")
goto HandleAltTab

!Tab::
+!Tab::
vKeepOpen := false
vIndex += InStr(A_ThisHotkey, "+") ? -1 : 1

HandleAltTab:
Gui, % hGui2 ":Default"
Gui, % hGui ":Default"

if !DllCall("user32\IsWindowVisible", "Ptr",hGui2)
if !DllCall("user32\IsWindowVisible", "Ptr",hGui)
{
    Hotkey, IfWinActive, % "ahk_id " hGui2
    Hotkey, IfWinActive, % "ahk_id " hGui
    Hotkey, *Esc, DoCancel, On
    LV_Delete(), IL_Destroy(hIL)
    hIL := IL_Create(28, 28, 1)
    LV_SetImageList(hIL)
    vCount := 0, vPrompt := "", oHWnd := {}, oTitle := {}, oHIcon := {}, oHIconBig := {}
    Loop % vListCount
    {
        if (A_Index = vListVisibleWindows)
        {
            DetectHiddenWindows, Off
            WinGet, vWinList, List
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd[vCount] := hWnd
                oTitle[vCount] := vFileName
                oHIcon[vCount] := JEE_WinGetIcon(hWnd, 1)
                oHIconBig[vCount] := JEE_WinGetIcon(hWnd, 1)
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)
                LV_ModifyCol(1, 40)
            }

            DetectHiddenWindows, On
        }

        vDesktopFound := false

        Loop, % oHWnd.MaxIndex()
        {
            if (oTitle[A_Index] = "Desktop")
            {
                vDesktopFound := true
                break
            }
        }

        if !vDesktopFound
        {
            vCount += 1
            oHWnd[vCount] := "Desktop"
            oTitle[vCount] := "Desktop"
            oHIcon[vCount] := hIconDT
            oHIconBig[vCount] := hIconDTBig
            IL_Add(hIL, "HICON:*" oHIcon[vCount])
            LV_Add("Icon" vCount)
        }

        if (A_Index = vListIntExpTabs)
        {
            WinGet, vWinList, List, ahk_class TabThumbnailWindow
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd.Push(hWnd)
                oTitle.Push(vFileName)
                oHIcon.Push(JEE_WinGetIcon(hWnd, 1))
                oHIconBig.Push(JEE_WinGetIcon(hWnd, 1))
                ToolTip, % "Title: " oTitle[vCount] " | Icon Index: " vCount
                Sleep, 500
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)
                LV_ModifyCol(1, 40)
            }

        }
    }

    ;Loop 2
    ;    LV_Add("Icon0", "")
    ;==============================
    vIndex := 2
    SetTimer, CheckAlt, 5
    SetTimer, HandleAltTab, 10

;---------GET CENTER OF CURRENT MONITOR---------
        ;get current monitor index
        CurrentMonitorIndex:=GetCurrentMonitorIndex()
        ;get Hwnd of current GUI
        DetectHiddenWindows On
        Gui, 2:Show, w457 H266
        Gui, +LastFound
        WinSet, TransColor, F0F0F0
        Gui, Show, w457 h266
        GUI_Hwnd := WinExist()
        ;Calculate size of GUI
        GetClientSize(GUI_Hwnd,GUI_Width,GUI_Height)
        DetectHiddenWindows Off
        ;Calculate where the GUI should be positioned
        GUI_X:=CoordXCenterScreen(GUI_Width,CurrentMonitorIndex)
        GUI_Y:=CoordYCenterScreen(GUI_Height,CurrentMonitorIndex)

        ;------- / GET CENTER OF CURRENT MONITOR---------
        ;SHOW GUI AT CENTER OF CURRENT SCREEN
        Gui, 2:Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Gui, Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Return

        GetCurrentMonitorIndex(){
        CoordMode, Mouse, Screen
        MouseGetPos, mx, my
        SysGet, monitorsCount, 80

        Loop %monitorsCount%{
            SysGet, monitor, Monitor, %A_Index%
            if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
                Return A_Index
                }
            }
            Return 1
    }

        CoordXCenterScreen(WidthOfGUI,ScreenNumber)
    {
        SysGet, Mon1, Monitor, %ScreenNumber%
        return (( Mon1Right-Mon1Left - WidthOfGUI ) / 2) + Mon1Left
    }

    CoordYCenterScreen(HeightofGUI,ScreenNumber){
        SysGet, Mon1, Monitor, %ScreenNumber%
        return ((Mon1Bottom-Mon1Top - 30 - HeightofGUI ) / 2) + Mon1Top
    }

    GetClientSize(hwnd, ByRef w, ByRef h)
    {
        VarSetCapacity(rc, 16)
        DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
        w := NumGet(rc, 8, "int")
        h := NumGet(rc, 12, "int")
    }
}

if (vIndex < 1)
    vIndex := vCount
if (vIndex > vCount)
    vIndex := 1

ControlSetText,, % oTitle[vIndex], % "ahk_id " hStc
SendMessage, 0x170, % oHIcon[vIndex], 0,, % "ahk_id " hStcImg ;STM_SETICON := 0x170

LV_Modify(0, "-Select")
LV_Modify(vIndex, "Vis")
LV_Modify(vIndex, "Select Vis")
return

;==================================================

CheckAlt:
if !GetKeyState("Alt", "P") && !vKeepOpen
{
    SetTimer, CheckAlt, Off
    SetTimer, HandleAltTab, Off
    if WinExist("ahk_id " hGui) {
        WinHide, ahk_id %hGui%
        if WinExist("ahk_id " hGui2)
            WinHide, ahk_id %hGui2%
    }
    DetectHiddenWindows, On
    if (oTitle[vIndex] = "Desktop")
    {
        DllCall("user32\ShowWindow", "Ptr", hGui2, "Int", 0)
        DllCall("user32\ShowWindow", "Ptr", hGui, "Int", 0)
        WinMinimizeAll
    }
    else
    {
        WinActivate, % "ahk_id " oHWnd[vIndex]
    }
}
return

;==================================================

#If WinActive("ahk_id " hGui2)
#If WinActive("ahk_id " hGui)

Tab::
Right::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

+Tab::
Left::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()

    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelUp::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelDown::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

Enter::
NumpadEnter::
Space::
    if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
        WinActivate, % "ahk_id " oHWnd[vIndex]
        vKeepOpen := false
        SetTimer, HandleAltTab, Off
        Gui, Hide
    }
return

Esc::
    vKeepOpen := false
    SetTimer, HandleAltTab, Off
    LV_Modify(0, "-Select")
    vIndex := 0
    Gui, 2:Hide
    Gui, Hide
return
#If

;==================================================

OnListViewClick:
    if (A_GuiEvent = "Normal") {
        LV_GetText(vSelectedTitle, A_EventInfo, 1)
        vIndex := A_EventInfo
        if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
            WinActivate, % "ahk_id " oHWnd[vIndex]
            vKeepOpen := false
            SetTimer, HandleAltTab, Off
            Gui, 2:Hide
            Gui, Hide
        }
    }
return

;==================================================

DoCancel:
SetTimer, CheckAlt, Off
Hotkey, IfWinActive, % "ahk_id " hGui2
Hotkey, IfWinActive, % "ahk_id " hGui
Hotkey, *Esc, DoCancel, Off
WinHide, % "ahk_id " hGui2
WinHide, % "ahk_id " hGui
return

;==================================================

JEE_WinGetIcon(hWnd, vDoGetBig:=0)
{
    static vSfx := (A_PtrSize=8) ? "Ptr" : ""
    if !hWnd || !WinExist("ahk_id " hWnd)
        return 0
    if vDoGetBig
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    else
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    return 0
}

;==================================================

JEE_WinHasTaskbarButton(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
    || DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    if DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
        return 0
    return 1
}

;==================================================

JEE_WinHasAltTabIcon(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
    || (vWinStyle & 0x8000000) ;WS_DISABLED := 0x8000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
    || (vWinExStyle & 0x8000000) ;WS_EX_NOACTIVATE := 0x8000000
        return 0
    return 1
}

;==================================================

WinSetRegion(hWnd, Radius := 20)
{
    hRgn := DllCall("gdi32\CreateRoundRectRgn", "Int", 0, "Int", 0, "Int", 457, "Int", 267, "Int", Radius, "Int", Radius, "Ptr")
    DllCall("user32\SetWindowRgn", "Ptr", hWnd, "Ptr", hRgn, "Int", 1)
}


1746726934678.webp

Code:
;Alt-Tab Reincarnation

#SingleInstance force
ListLines, Off
#KeyHistory 0
Menu, Tray, Click, 1
;Menu, Tray, NoIcon
#NoEnv
AutoTrim, Off
#UseHook
#MaxThreadsPerHotKey 2

SetKeyDelay, 0, 20

SplitPath, A_ScriptName,,,, vScriptNameNoExt
Menu, Tray, Tip, % vScriptNameNoExt

;==================================================

vListVisibleWindows := 1
vListCount := 4

;==================================================

hIcon := DllCall("user32\LoadIcon", Ptr,0, Ptr,32512, Ptr) ;IDI_APPLICATION := 32512
hIconDT := LoadPicture("shell32.dll", "w16 h16 icon35", vType)
hIconDTBig := LoadPicture("shell32.dll", "w32 h32 icon35", vType)

Gui, 2:New, +HwndhGui2 -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, 2:Color, DEDEDE
Gui, 2:Font, s11, Consolas
Gui, 2:Add, ListView, x-2 y20 w480 h210 +LV0x3 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +BackgroundDEDEDE

Gui, New, +HwndhGui -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, Font, s11, Consolas
Gui, Color, DEDEDE
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y230 w415 h28 vMyLabel BackgroundDEDEDE, Embossed Window
Gui, Add, ListView, x-2 y20 w480 h210 +LV0x3 +LV0x8000 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +BackgroundDEDEDE
return
 
;==================================================

GuiClose:
Gui, 2:Hide
ExitApp
return

;==================================================

^!Tab::
vKeepOpen := true
vIndex++
if (vIndex > oHWnd.MaxIndex())
    vIndex := 1
LV_Modify(0, "-Select")
LV_Modify(vIndex, "Select Vis")
goto HandleAltTab

!Tab::
+!Tab::
vKeepOpen := false
vIndex += InStr(A_ThisHotkey, "+") ? -1 : 1

HandleAltTab:
Gui, % hGui2 ":Default"
Gui, % hGui ":Default"

if !DllCall("user32\IsWindowVisible", "Ptr",hGui2)
if !DllCall("user32\IsWindowVisible", "Ptr",hGui)
{
    Hotkey, IfWinActive, % "ahk_id " hGui2
    Hotkey, IfWinActive, % "ahk_id " hGui
    Hotkey, *Esc, DoCancel, On
    LV_Delete(), IL_Destroy(hIL)
    hIL := IL_Create(28, 28, 1)
    LV_SetImageList(hIL)
    vCount := 0, vPrompt := "", oHWnd := {}, oTitle := {}, oHIcon := {}, oHIconBig := {}
    Loop % vListCount
    {
        if (A_Index = vListVisibleWindows)
        {
            DetectHiddenWindows, Off
            WinGet, vWinList, List
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd[vCount] := hWnd
                oTitle[vCount] := vFileName
                oHIcon[vCount] := JEE_WinGetIcon(hWnd, 1)
                oHIconBig[vCount] := JEE_WinGetIcon(hWnd, 1)
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)
                LV_ModifyCol(1, 40)
            }

            DetectHiddenWindows, On
        }

        vDesktopFound := false

        Loop, % oHWnd.MaxIndex()
        {
            if (oTitle[A_Index] = "Desktop")
            {
                vDesktopFound := true
                break
            }
        }

        if !vDesktopFound
        {
            vCount += 1
            oHWnd[vCount] := "Desktop"
            oTitle[vCount] := "Desktop"
            oHIcon[vCount] := hIconDT
            oHIconBig[vCount] := hIconDTBig
            IL_Add(hIL, "HICON:*" oHIcon[vCount])
            LV_Add("Icon" vCount)
        }

        if (A_Index = vListIntExpTabs)
        {
            WinGet, vWinList, List, ahk_class TabThumbnailWindow
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd.Push(hWnd)
                oTitle.Push(vFileName)
                oHIcon.Push(JEE_WinGetIcon(hWnd, 1))
                oHIconBig.Push(JEE_WinGetIcon(hWnd, 1))
                ToolTip, % "Title: " oTitle[vCount] " | Icon Index: " vCount
                Sleep, 500
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)
                LV_ModifyCol(1, 40)
            }

        }
    }

    ;Loop 2
    ;    LV_Add("Icon0", "")
    ;==============================
    vIndex := 2
    WinSetRegion(hGui2, 20)
    WinSetRegion(hGui, 20)
    SetTimer, CheckAlt, 5
    SetTimer, HandleAltTab, 10

;---------GET CENTER OF CURRENT MONITOR---------
        ;get current monitor index
        CurrentMonitorIndex:=GetCurrentMonitorIndex()
        ;get Hwnd of current GUI
        DetectHiddenWindows On
        Gui, 2:Show, w457 H266
        Gui, +LastFound
        WinSet, TransColor, F0F0F0
        Gui, Show, w457 h266
        GUI_Hwnd := WinExist()
        ;Calculate size of GUI
        GetClientSize(GUI_Hwnd,GUI_Width,GUI_Height)
        DetectHiddenWindows Off
        ;Calculate where the GUI should be positioned
        GUI_X:=CoordXCenterScreen(GUI_Width,CurrentMonitorIndex)
        GUI_Y:=CoordYCenterScreen(GUI_Height,CurrentMonitorIndex)

        ;------- / GET CENTER OF CURRENT MONITOR---------
        ;SHOW GUI AT CENTER OF CURRENT SCREEN
        Gui, 2:Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Gui, Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Return

        GetCurrentMonitorIndex(){
        CoordMode, Mouse, Screen
        MouseGetPos, mx, my
        SysGet, monitorsCount, 80

        Loop %monitorsCount%{
            SysGet, monitor, Monitor, %A_Index%
            if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
                Return A_Index
                }
            }
            Return 1
    }

        CoordXCenterScreen(WidthOfGUI,ScreenNumber)
    {
        SysGet, Mon1, Monitor, %ScreenNumber%
        return (( Mon1Right-Mon1Left - WidthOfGUI ) / 2) + Mon1Left
    }

    CoordYCenterScreen(HeightofGUI,ScreenNumber){
        SysGet, Mon1, Monitor, %ScreenNumber%
        return ((Mon1Bottom-Mon1Top - 30 - HeightofGUI ) / 2) + Mon1Top
    }

    GetClientSize(hwnd, ByRef w, ByRef h)
    {
        VarSetCapacity(rc, 16)
        DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
        w := NumGet(rc, 8, "int")
        h := NumGet(rc, 12, "int")
    }
}

if (vIndex < 1)
    vIndex := vCount
if (vIndex > vCount)
    vIndex := 1

ControlSetText,, % oTitle[vIndex], % "ahk_id " hStc
SendMessage, 0x170, % oHIcon[vIndex], 0,, % "ahk_id " hStcImg ;STM_SETICON := 0x170

LV_Modify(0, "-Select")
LV_Modify(vIndex, "Vis")
LV_Modify(vIndex, "Select Vis")
return

;==================================================

CheckAlt:
if !GetKeyState("Alt", "P") && !vKeepOpen
{
    SetTimer, CheckAlt, Off
    SetTimer, HandleAltTab, Off
    if WinExist("ahk_id " hGui) {
        WinHide, ahk_id %hGui%
        if WinExist("ahk_id " hGui2)
            WinHide, ahk_id %hGui2%
    }
    DetectHiddenWindows, On
    if (oTitle[vIndex] = "Desktop")
    {
        DllCall("user32\ShowWindow", "Ptr", hGui2, "Int", 0)
        DllCall("user32\ShowWindow", "Ptr", hGui, "Int", 0)
        WinMinimizeAll
    }
    else
    {
        WinActivate, % "ahk_id " oHWnd[vIndex]
    }
}
return

;==================================================

#If WinActive("ahk_id " hGui2)
#If WinActive("ahk_id " hGui)

Tab::
Right::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

+Tab::
Left::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()

    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelUp::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelDown::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

Enter::
NumpadEnter::
Space::
    if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
        WinActivate, % "ahk_id " oHWnd[vIndex]
        vKeepOpen := false
        SetTimer, HandleAltTab, Off
        Gui, Hide
    }
return

Esc::
    vKeepOpen := false
    SetTimer, HandleAltTab, Off
    LV_Modify(0, "-Select")
    vIndex := 0
    Gui, 2:Hide
    Gui, Hide
return
#If

;==================================================

OnListViewClick:
    if (A_GuiEvent = "Normal") {
        LV_GetText(vSelectedTitle, A_EventInfo, 1)
        vIndex := A_EventInfo
        if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
            WinActivate, % "ahk_id " oHWnd[vIndex]
            vKeepOpen := false
            SetTimer, HandleAltTab, Off
            Gui, 2:Hide
            Gui, Hide
        }
    }
return

;==================================================

DoCancel:
SetTimer, CheckAlt, Off
Hotkey, IfWinActive, % "ahk_id " hGui2
Hotkey, IfWinActive, % "ahk_id " hGui
Hotkey, *Esc, DoCancel, Off
WinHide, % "ahk_id " hGui2
WinHide, % "ahk_id " hGui
return

;==================================================

JEE_WinGetIcon(hWnd, vDoGetBig:=0)
{
    static vSfx := (A_PtrSize=8) ? "Ptr" : ""
    if !hWnd || !WinExist("ahk_id " hWnd)
        return 0
    if vDoGetBig
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    else
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    return 0
}

;==================================================

JEE_WinHasTaskbarButton(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
    || DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    if DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
        return 0
    return 1
}

;==================================================

JEE_WinHasAltTabIcon(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
    || (vWinStyle & 0x8000000) ;WS_DISABLED := 0x8000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
    || (vWinExStyle & 0x8000000) ;WS_EX_NOACTIVATE := 0x8000000
        return 0
    return 1
}

;==================================================

WinSetRegion(hWnd, Radius := 20)
{
    hRgn := DllCall("gdi32\CreateRoundRectRgn", "Int", 0, "Int", 0, "Int", 457, "Int", 267, "Int", Radius, "Int", Radius, "Ptr")
    DllCall("user32\SetWindowRgn", "Ptr", hWnd, "Ptr", hRgn, "Int", 1)
}
_______________________________________________________________________________________________________________________________________________
Base Outline Used for AHK coding (heavily modified from this, but just in case someone likes a list style more):
.https://www.autohotkey.com/boards/viewtopic.php?t=37184
1746491852413.webp

_______________________________________________________________________________________________________________________________________________
 

Attachments

Last edited:

My Computer

System One

  • OS
    Windows 11 Pro
R-Alt>L-Alt+Tab

9732.webp
 

My Computers

System One System Two

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    ASUS ROG Strix
  • Operating System
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    ASUS VivoBook
All Light Mode Highlight EXEs are attached to post as ZIPs
1746722358045.webp
Code:
;Alt-Tab Reincarnation

#SingleInstance force
ListLines, Off
#KeyHistory 0
Menu, Tray, Click, 1
;Menu, Tray, NoIcon
#NoEnv
AutoTrim, Off
#UseHook
#MaxThreadsPerHotKey 2

SetKeyDelay, 0, 20

SplitPath, A_ScriptName,,,, vScriptNameNoExt
Menu, Tray, Tip, % vScriptNameNoExt

;==================================================

vListVisibleWindows := 1
vListCount := 4

;==================================================

hIcon := DllCall("user32\LoadIcon", Ptr,0, Ptr,32512, Ptr) ;IDI_APPLICATION := 32512
hIconDT := LoadPicture("shell32.dll", "w16 h16 icon35", vType)
hIconDTBig := LoadPicture("shell32.dll", "w32 h32 icon35", vType)

Gui, New, +HwndhGui -Caption, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, Font, s11, Consolas
Gui, Color, DEDEDE
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y80 w415 h28 vMyLabel BackgroundDEDEDE, Embossed Window
Gui, Add, ListView, x-2 y20 w480 h60 +LV0x3 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +BackgroundDEDEDE
return
    
;==================================================

GuiClose:
ExitApp
return

;==================================================

^!Tab::
vKeepOpen := true
vIndex++
if (vIndex > oHWnd.MaxIndex())
    vIndex := 1
LV_Modify(0, "-Select")
LV_Modify(vIndex, "Select Vis")
goto HandleAltTab

!Tab::
+!Tab::
vKeepOpen := false
vIndex += InStr(A_ThisHotkey, "+") ? -1 : 1

HandleAltTab:
Gui, % hGui ":Default"

if !DllCall("user32\IsWindowVisible", "Ptr",hGui)
{
    Hotkey, IfWinActive, % "ahk_id " hGui
    Hotkey, *Esc, DoCancel, On
    LV_Delete(), IL_Destroy(hIL)
    hIL := IL_Create(28, 28, 1)
    LV_SetImageList(hIL)
    vCount := 0, vPrompt := "", oHWnd := {}, oTitle := {}, oHIcon := {}, oHIconBig := {}
    Loop % vListCount
    {
        if (A_Index = vListVisibleWindows)
        {
            DetectHiddenWindows, Off
            WinGet, vWinList, List
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd[vCount] := hWnd
                oTitle[vCount] := vFileName
                oHIcon[vCount] := JEE_WinGetIcon(hWnd, 1)
                oHIconBig[vCount] := JEE_WinGetIcon(hWnd, 1)
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)    
                LV_ModifyCol(1, 40)  
            }

            DetectHiddenWindows, On
        }

        vDesktopFound := false

        Loop, % oHWnd.MaxIndex()
        {
            if (oTitle[A_Index] = "Desktop")
            {
                vDesktopFound := true
                break
            }
        }

        if !vDesktopFound
        {
            vCount += 1
            oHWnd[vCount] := "Desktop"
            oTitle[vCount] := "Desktop"
            oHIcon[vCount] := hIconDT
            oHIconBig[vCount] := hIconDTBig
            IL_Add(hIL, "HICON:*" oHIcon[vCount])
            LV_Add("Icon" vCount)  
        }

        if (A_Index = vListIntExpTabs)
        {
            WinGet, vWinList, List, ahk_class TabThumbnailWindow
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd.Push(hWnd)
                oTitle.Push(vFileName)
                oHIcon.Push(JEE_WinGetIcon(hWnd, 1))
                oHIconBig.Push(JEE_WinGetIcon(hWnd, 1))
                ToolTip, % "Title: " oTitle[vCount] " | Icon Index: " vCount
                Sleep, 500
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)    
                LV_ModifyCol(1, 40)  
            }

        }
    }

    ;Loop 2
    ;    LV_Add("Icon0", "")
    ;==============================
    vIndex := 2
    WinSetRegion(hGui, 0)
    SetTimer, CheckAlt, 5
    SetTimer, HandleAltTab, 10

;---------GET CENTER OF CURRENT MONITOR---------
        ;get current monitor index
        CurrentMonitorIndex:=GetCurrentMonitorIndex()
        ;get Hwnd of current GUI
        DetectHiddenWindows On
        Gui, +LastFound
        Gui, Show, w457 h117
        GUI_Hwnd := WinExist()
        ;Calculate size of GUI
        GetClientSize(GUI_Hwnd,GUI_Width,GUI_Height)
        DetectHiddenWindows Off
        ;Calculate where the GUI should be positioned
        GUI_X:=CoordXCenterScreen(GUI_Width,CurrentMonitorIndex)
        GUI_Y:=CoordYCenterScreen(GUI_Height,CurrentMonitorIndex)

        ;------- / GET CENTER OF CURRENT MONITOR--------- 
        ;SHOW GUI AT CENTER OF CURRENT SCREEN
        Gui, Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Return

        GetCurrentMonitorIndex(){
        CoordMode, Mouse, Screen
        MouseGetPos, mx, my
        SysGet, monitorsCount, 80

        Loop %monitorsCount%{
            SysGet, monitor, Monitor, %A_Index%
            if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
                Return A_Index
                }
            }
            Return 1
    }

        CoordXCenterScreen(WidthOfGUI,ScreenNumber)
    {
        SysGet, Mon1, Monitor, %ScreenNumber%
        return (( Mon1Right-Mon1Left - WidthOfGUI ) / 2) + Mon1Left
    }

    CoordYCenterScreen(HeightofGUI,ScreenNumber){
        SysGet, Mon1, Monitor, %ScreenNumber%
        return ((Mon1Bottom-Mon1Top - 30 - HeightofGUI ) / 2) + Mon1Top
    }

    GetClientSize(hwnd, ByRef w, ByRef h)
    {
        VarSetCapacity(rc, 16)
        DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
        w := NumGet(rc, 8, "int")
        h := NumGet(rc, 12, "int")
    }
}

if (vIndex < 1)
    vIndex := vCount
if (vIndex > vCount)
    vIndex := 1

ControlSetText,, % oTitle[vIndex], % "ahk_id " hStc
SendMessage, 0x170, % oHIcon[vIndex], 0,, % "ahk_id " hStcImg ;STM_SETICON := 0x170

LV_Modify(0, "-Select")
LV_Modify(vIndex, "Vis")
LV_Modify(vIndex, "Select Vis")
return

;==================================================

CheckAlt:
if !GetKeyState("Alt", "P") && !vKeepOpen
{
    SetTimer, CheckAlt, Off
    SetTimer, HandleAltTab, Off
    WinHide, % "ahk_id " hGui
    DetectHiddenWindows, On
    if (oTitle[vIndex] = "Desktop")
    {
        DllCall("user32\ShowWindow", "Ptr", hGui, "Int", 0)
        WinMinimizeAll
    }
    else 
    {
        WinActivate, % "ahk_id " oHWnd[vIndex]
    }
}
return

;==================================================

#If WinActive("ahk_id " hGui)

Tab::
Right::
    if (vIndex < vCount) 
        vIndex++
    else 
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

+Tab::
Left::
    if (vIndex > 1) 
        vIndex--
    else 
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelUp::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelDown::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

Enter::
NumpadEnter::
Space::
    if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
        WinActivate, % "ahk_id " oHWnd[vIndex]
        vKeepOpen := false
        SetTimer, HandleAltTab, Off
        Gui, Hide
    }
return

Esc::
    vKeepOpen := false
    SetTimer, HandleAltTab, Off
    LV_Modify(0, "-Select")
    vIndex := 0  
    Gui, Hide
return

#If

;==================================================

OnListViewClick:
    if (A_GuiEvent = "Normal") {
        LV_GetText(vSelectedTitle, A_EventInfo, 1)
        vIndex := A_EventInfo
        if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
            WinActivate, % "ahk_id " oHWnd[vIndex]
            vKeepOpen := false
            SetTimer, HandleAltTab, Off
            Gui, Hide
        }
    }
return

;==================================================

DoCancel:
SetTimer, CheckAlt, Off
Hotkey, IfWinActive, % "ahk_id " hGui
Hotkey, *Esc, DoCancel, Off
WinHide, % "ahk_id " hGui
return

;==================================================

JEE_WinGetIcon(hWnd, vDoGetBig:=0)
{
    static vSfx := (A_PtrSize=8) ? "Ptr" : ""
    if !hWnd || !WinExist("ahk_id " hWnd)
        return 0
    if vDoGetBig
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    else
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    return 0
}

;==================================================

JEE_WinHasTaskbarButton(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
    || DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    if DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
        return 0
    return 1
}

;==================================================

JEE_WinHasAltTabIcon(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
    || (vWinStyle & 0x8000000) ;WS_DISABLED := 0x8000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
    || (vWinExStyle & 0x8000000) ;WS_EX_NOACTIVATE := 0x8000000
        return 0
    return 1
}

;==================================================

WinSetRegion(hWnd, Radius := 20)
{
    hRgn := DllCall("gdi32\CreateRoundRectRgn", "Int", 0, "Int", 0, "Int", 457, "Int", 117, "Int", Radius, "Int", Radius, "Ptr")
    DllCall("user32\SetWindowRgn", "Ptr", hWnd, "Ptr", hRgn, "Int", 1)
}


1746722473997.webp


Code:
;Alt-Tab Reincarnation

#SingleInstance force
ListLines, Off
#KeyHistory 0
Menu, Tray, Click, 1
;Menu, Tray, NoIcon
#NoEnv
AutoTrim, Off
#UseHook
#MaxThreadsPerHotKey 2

SetKeyDelay, 0, 20

SplitPath, A_ScriptName,,,, vScriptNameNoExt
Menu, Tray, Tip, % vScriptNameNoExt

;==================================================

vListVisibleWindows := 1
vListCount := 4

;==================================================

hIcon := DllCall("user32\LoadIcon", Ptr,0, Ptr,32512, Ptr) ;IDI_APPLICATION := 32512
hIconDT := LoadPicture("shell32.dll", "w16 h16 icon35", vType)
hIconDTBig := LoadPicture("shell32.dll", "w32 h32 icon35", vType)

Gui, New, +HwndhGui -Caption, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, Font, s11, Consolas
Gui, Color, DEDEDE
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y80 w415 h28 vMyLabel BackgroundDEDEDE, Embossed Window
Gui, Add, ListView, x-2 y20 w480 h60 +LV0x3 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +BackgroundDEDEDE
return
 
;==================================================

GuiClose:
ExitApp
return

;==================================================

^!Tab::
vKeepOpen := true
vIndex++
if (vIndex > oHWnd.MaxIndex())
    vIndex := 1
LV_Modify(0, "-Select")
LV_Modify(vIndex, "Select Vis")
goto HandleAltTab

!Tab::
+!Tab::
vKeepOpen := false
vIndex += InStr(A_ThisHotkey, "+") ? -1 : 1

HandleAltTab:
Gui, % hGui ":Default"

if !DllCall("user32\IsWindowVisible", "Ptr",hGui)
{
    Hotkey, IfWinActive, % "ahk_id " hGui
    Hotkey, *Esc, DoCancel, On
    LV_Delete(), IL_Destroy(hIL)
    hIL := IL_Create(28, 28, 1)
    LV_SetImageList(hIL)
    vCount := 0, vPrompt := "", oHWnd := {}, oTitle := {}, oHIcon := {}, oHIconBig := {}
    Loop % vListCount
    {
        if (A_Index = vListVisibleWindows)
        {
            DetectHiddenWindows, Off
            WinGet, vWinList, List
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd[vCount] := hWnd
                oTitle[vCount] := vFileName
                oHIcon[vCount] := JEE_WinGetIcon(hWnd, 1)
                oHIconBig[vCount] := JEE_WinGetIcon(hWnd, 1)
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)
                LV_ModifyCol(1, 40)
            }

            DetectHiddenWindows, On
        }

        vDesktopFound := false

        Loop, % oHWnd.MaxIndex()
        {
            if (oTitle[A_Index] = "Desktop")
            {
                vDesktopFound := true
                break
            }
        }

        if !vDesktopFound
        {
            vCount += 1
            oHWnd[vCount] := "Desktop"
            oTitle[vCount] := "Desktop"
            oHIcon[vCount] := hIconDT
            oHIconBig[vCount] := hIconDTBig
            IL_Add(hIL, "HICON:*" oHIcon[vCount])
            LV_Add("Icon" vCount)
        }

        if (A_Index = vListIntExpTabs)
        {
            WinGet, vWinList, List, ahk_class TabThumbnailWindow
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd.Push(hWnd)
                oTitle.Push(vFileName)
                oHIcon.Push(JEE_WinGetIcon(hWnd, 1))
                oHIconBig.Push(JEE_WinGetIcon(hWnd, 1))
                ToolTip, % "Title: " oTitle[vCount] " | Icon Index: " vCount
                Sleep, 500
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)
                LV_ModifyCol(1, 40)
            }

        }
    }

    ;Loop 2
    ;    LV_Add("Icon0", "")
    ;==============================
    vIndex := 2
    WinSetRegion(hGui, 20)
    SetTimer, CheckAlt, 5
    SetTimer, HandleAltTab, 10

;---------GET CENTER OF CURRENT MONITOR---------
        ;get current monitor index
        CurrentMonitorIndex:=GetCurrentMonitorIndex()
        ;get Hwnd of current GUI
        DetectHiddenWindows On
        Gui, +LastFound
        Gui, Show, w457 h117
        GUI_Hwnd := WinExist()
        ;Calculate size of GUI
        GetClientSize(GUI_Hwnd,GUI_Width,GUI_Height)
        DetectHiddenWindows Off
        ;Calculate where the GUI should be positioned
        GUI_X:=CoordXCenterScreen(GUI_Width,CurrentMonitorIndex)
        GUI_Y:=CoordYCenterScreen(GUI_Height,CurrentMonitorIndex)

        ;------- / GET CENTER OF CURRENT MONITOR---------
        ;SHOW GUI AT CENTER OF CURRENT SCREEN
        Gui, Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Return

        GetCurrentMonitorIndex(){
        CoordMode, Mouse, Screen
        MouseGetPos, mx, my
        SysGet, monitorsCount, 80

        Loop %monitorsCount%{
            SysGet, monitor, Monitor, %A_Index%
            if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
                Return A_Index
                }
            }
            Return 1
    }

        CoordXCenterScreen(WidthOfGUI,ScreenNumber)
    {
        SysGet, Mon1, Monitor, %ScreenNumber%
        return (( Mon1Right-Mon1Left - WidthOfGUI ) / 2) + Mon1Left
    }

    CoordYCenterScreen(HeightofGUI,ScreenNumber){
        SysGet, Mon1, Monitor, %ScreenNumber%
        return ((Mon1Bottom-Mon1Top - 30 - HeightofGUI ) / 2) + Mon1Top
    }

    GetClientSize(hwnd, ByRef w, ByRef h)
    {
        VarSetCapacity(rc, 16)
        DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
        w := NumGet(rc, 8, "int")
        h := NumGet(rc, 12, "int")
    }
}

if (vIndex < 1)
    vIndex := vCount
if (vIndex > vCount)
    vIndex := 1

ControlSetText,, % oTitle[vIndex], % "ahk_id " hStc
SendMessage, 0x170, % oHIcon[vIndex], 0,, % "ahk_id " hStcImg ;STM_SETICON := 0x170

LV_Modify(0, "-Select")
LV_Modify(vIndex, "Vis")
LV_Modify(vIndex, "Select Vis")
return

;==================================================

CheckAlt:
if !GetKeyState("Alt", "P") && !vKeepOpen
{
    SetTimer, CheckAlt, Off
    SetTimer, HandleAltTab, Off
    WinHide, % "ahk_id " hGui
    DetectHiddenWindows, On
    if (oTitle[vIndex] = "Desktop")
    {
        DllCall("user32\ShowWindow", "Ptr", hGui, "Int", 0)
        WinMinimizeAll
    }
    else
    {
        WinActivate, % "ahk_id " oHWnd[vIndex]
    }
}
return

;==================================================

#If WinActive("ahk_id " hGui)

Tab::
Right::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

+Tab::
Left::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelUp::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelDown::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

Enter::
NumpadEnter::
Space::
    if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
        WinActivate, % "ahk_id " oHWnd[vIndex]
        vKeepOpen := false
        SetTimer, HandleAltTab, Off
        Gui, Hide
    }
return

Esc::
    vKeepOpen := false
    SetTimer, HandleAltTab, Off
    LV_Modify(0, "-Select")
    vIndex := 0
    Gui, Hide
return

#If

;==================================================

OnListViewClick:
    if (A_GuiEvent = "Normal") {
        LV_GetText(vSelectedTitle, A_EventInfo, 1)
        vIndex := A_EventInfo
        if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
            WinActivate, % "ahk_id " oHWnd[vIndex]
            vKeepOpen := false
            SetTimer, HandleAltTab, Off
            Gui, Hide
        }
    }
return

;==================================================

DoCancel:
SetTimer, CheckAlt, Off
Hotkey, IfWinActive, % "ahk_id " hGui
Hotkey, *Esc, DoCancel, Off
WinHide, % "ahk_id " hGui
return

;==================================================

JEE_WinGetIcon(hWnd, vDoGetBig:=0)
{
    static vSfx := (A_PtrSize=8) ? "Ptr" : ""
    if !hWnd || !WinExist("ahk_id " hWnd)
        return 0
    if vDoGetBig
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    else
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    return 0
}

;==================================================

JEE_WinHasTaskbarButton(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
    || DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    if DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
        return 0
    return 1
}

;==================================================

JEE_WinHasAltTabIcon(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
    || (vWinStyle & 0x8000000) ;WS_DISABLED := 0x8000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
    || (vWinExStyle & 0x8000000) ;WS_EX_NOACTIVATE := 0x8000000
        return 0
    return 1
}

;==================================================

WinSetRegion(hWnd, Radius := 20)
{
    hRgn := DllCall("gdi32\CreateRoundRectRgn", "Int", 0, "Int", 0, "Int", 457, "Int", 117, "Int", Radius, "Int", Radius, "Ptr")
    DllCall("user32\SetWindowRgn", "Ptr", hWnd, "Ptr", hRgn, "Int", 1)
}


1746722541457.webp
Code:
;Alt-Tab Reincarnation

#SingleInstance force
ListLines, Off
#KeyHistory 0
Menu, Tray, Click, 1
;Menu, Tray, NoIcon
#NoEnv
AutoTrim, Off
#UseHook
#MaxThreadsPerHotKey 2

SetKeyDelay, 0, 20

SplitPath, A_ScriptName,,,, vScriptNameNoExt
Menu, Tray, Tip, % vScriptNameNoExt

;==================================================

vListVisibleWindows := 1
vListCount := 4

;==================================================

hIcon := DllCall("user32\LoadIcon", Ptr,0, Ptr,32512, Ptr) ;IDI_APPLICATION := 32512
hIconDT := LoadPicture("shell32.dll", "w16 h16 icon35", vType)
hIconDTBig := LoadPicture("shell32.dll", "w32 h32 icon35", vType)

Gui, New, +HwndhGui -Caption, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, Font, s11, Consolas
Gui, Color, DEDEDE
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y230 w415 h28 vMyLabel BackgroundDEDEDE, Embossed Window
Gui, Add, ListView, x-2 y20 w480 h210 +LV0x3 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +BackgroundDEDEDE
return
 
;==================================================

GuiClose:
ExitApp
return

;==================================================

^!Tab::
vKeepOpen := true
vIndex++
if (vIndex > oHWnd.MaxIndex())
    vIndex := 1
LV_Modify(0, "-Select")
LV_Modify(vIndex, "Select Vis")
goto HandleAltTab

!Tab::
+!Tab::
vKeepOpen := false
vIndex += InStr(A_ThisHotkey, "+") ? -1 : 1

HandleAltTab:
Gui, % hGui ":Default"

if !DllCall("user32\IsWindowVisible", "Ptr",hGui)
{
    Hotkey, IfWinActive, % "ahk_id " hGui
    Hotkey, *Esc, DoCancel, On
    LV_Delete(), IL_Destroy(hIL)
    hIL := IL_Create(28, 28, 1)
    LV_SetImageList(hIL)
    vCount := 0, vPrompt := "", oHWnd := {}, oTitle := {}, oHIcon := {}, oHIconBig := {}
    Loop % vListCount
    {
        if (A_Index = vListVisibleWindows)
        {
            DetectHiddenWindows, Off
            WinGet, vWinList, List
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd[vCount] := hWnd
                oTitle[vCount] := vFileName
                oHIcon[vCount] := JEE_WinGetIcon(hWnd, 1)
                oHIconBig[vCount] := JEE_WinGetIcon(hWnd, 1)
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)
                LV_ModifyCol(1, 40)
            }

            DetectHiddenWindows, On
        }
 
        vDesktopFound := false

        Loop, % oHWnd.MaxIndex()
        {
            if (oTitle[A_Index] = "Desktop")
            {
                vDesktopFound := true
                break
            }
        }

        if !vDesktopFound
        {
            vCount += 1
            oHWnd[vCount] := "Desktop"
            oTitle[vCount] := "Desktop"
            oHIcon[vCount] := hIconDT
            oHIconBig[vCount] := hIconDTBig
            IL_Add(hIL, "HICON:*" oHIcon[vCount])
            LV_Add("Icon" vCount)
        }

        if (A_Index = vListIntExpTabs)
        {
            WinGet, vWinList, List, ahk_class TabThumbnailWindow
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd.Push(hWnd)
                oTitle.Push(vFileName)
                oHIcon.Push(JEE_WinGetIcon(hWnd, 1))
                oHIconBig.Push(JEE_WinGetIcon(hWnd, 1))
                ToolTip, % "Title: " oTitle[vCount] " | Icon Index: " vCount
                Sleep, 500
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)
                LV_ModifyCol(1, 40)
            }
        }
    }

    ;Loop 2
    ;    LV_Add("Icon0", "")
    ;==============================
    vIndex := 2
    WinSetRegion(hGui, 0)
    SetTimer, CheckAlt, 5
    SetTimer, HandleAltTab, 10

;---------GET CENTER OF CURRENT MONITOR---------
        ;get current monitor index
        CurrentMonitorIndex:=GetCurrentMonitorIndex()
        ;get Hwnd of current GUI
        DetectHiddenWindows On
        Gui, +LastFound
        Gui, Show, w457 h266
        GUI_Hwnd := WinExist()
        ;Calculate size of GUI
        GetClientSize(GUI_Hwnd,GUI_Width,GUI_Height)
        DetectHiddenWindows Off
        ;Calculate where the GUI should be positioned
        GUI_X:=CoordXCenterScreen(GUI_Width,CurrentMonitorIndex)
        GUI_Y:=CoordYCenterScreen(GUI_Height,CurrentMonitorIndex)

        ;------- / GET CENTER OF CURRENT MONITOR---------
        ;SHOW GUI AT CENTER OF CURRENT SCREEN
        Gui, Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Return

        GetCurrentMonitorIndex(){
        CoordMode, Mouse, Screen
        MouseGetPos, mx, my
        SysGet, monitorsCount, 80

        Loop %monitorsCount%{
            SysGet, monitor, Monitor, %A_Index%
            if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
                Return A_Index
                }
            }
            Return 1
    }

        CoordXCenterScreen(WidthOfGUI,ScreenNumber)
    {
        SysGet, Mon1, Monitor, %ScreenNumber%
        return (( Mon1Right-Mon1Left - WidthOfGUI ) / 2) + Mon1Left
    }

    CoordYCenterScreen(HeightofGUI,ScreenNumber){
        SysGet, Mon1, Monitor, %ScreenNumber%
        return ((Mon1Bottom-Mon1Top - 30 - HeightofGUI ) / 2) + Mon1Top
    }

    GetClientSize(hwnd, ByRef w, ByRef h)
    {
        VarSetCapacity(rc, 16)
        DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
        w := NumGet(rc, 8, "int")
        h := NumGet(rc, 12, "int")
    }
}

if (vIndex < 1)
    vIndex := vCount
if (vIndex > vCount)
    vIndex := 1

ControlSetText,, % oTitle[vIndex], % "ahk_id " hStc
SendMessage, 0x170, % oHIcon[vIndex], 0,, % "ahk_id " hStcImg ;STM_SETICON := 0x170

LV_Modify(0, "-Select")
LV_Modify(vIndex, "Vis")
LV_Modify(vIndex, "Select Vis")
return

;==================================================

CheckAlt:
if !GetKeyState("Alt", "P") && !vKeepOpen
{
    SetTimer, CheckAlt, Off
    SetTimer, HandleAltTab, Off
    WinHide, % "ahk_id " hGui
    DetectHiddenWindows, On
    if (oTitle[vIndex] = "Desktop")
    {
        DllCall("user32\ShowWindow", "Ptr", hGui, "Int", 0)
        WinMinimizeAll
    }
    else
    {
        WinActivate, % "ahk_id " oHWnd[vIndex]
    }
}
return

;==================================================

#If WinActive("ahk_id " hGui)

Tab::
Right::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

+Tab::
Left::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()

    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelUp::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelDown::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

Enter::
NumpadEnter::
Space::
    if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
        WinActivate, % "ahk_id " oHWnd[vIndex]
        vKeepOpen := false
        SetTimer, HandleAltTab, Off
        Gui, Hide
    }
return

Esc::
    vKeepOpen := false
    SetTimer, HandleAltTab, Off
    LV_Modify(0, "-Select")
    vIndex := 0
    Gui, Hide
return

#If

;==================================================

OnListViewClick:
    if (A_GuiEvent = "Normal") {
        LV_GetText(vSelectedTitle, A_EventInfo, 1)
        vIndex := A_EventInfo
        if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
            WinActivate, % "ahk_id " oHWnd[vIndex]
            vKeepOpen := false
            SetTimer, HandleAltTab, Off
            Gui, Hide
        }
    }
return

;==================================================

DoCancel:
SetTimer, CheckAlt, Off
Hotkey, IfWinActive, % "ahk_id " hGui
Hotkey, *Esc, DoCancel, Off
WinHide, % "ahk_id " hGui
return

;==================================================

JEE_WinGetIcon(hWnd, vDoGetBig:=0)
{
    static vSfx := (A_PtrSize=8) ? "Ptr" : ""
    if !hWnd || !WinExist("ahk_id " hWnd)
        return 0
    if vDoGetBig
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    else
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    return 0
}

;==================================================

JEE_WinHasTaskbarButton(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
    || DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    if DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
        return 0
    return 1
}

;==================================================

JEE_WinHasAltTabIcon(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
    || (vWinStyle & 0x8000000) ;WS_DISABLED := 0x8000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
    || (vWinExStyle & 0x8000000) ;WS_EX_NOACTIVATE := 0x8000000
        return 0
    return 1
}

;==================================================

WinSetRegion(hWnd, Radius := 20)
{
    hRgn := DllCall("gdi32\CreateRoundRectRgn", "Int", 0, "Int", 0, "Int", 457, "Int", 267, "Int", Radius, "Int", Radius, "Ptr")
    DllCall("user32\SetWindowRgn", "Ptr", hWnd, "Ptr", hRgn, "Int", 1)
}


1746722597672.webp

Code:
;Alt-Tab Reincarnation

#SingleInstance force
ListLines, Off
#KeyHistory 0
Menu, Tray, Click, 1
;Menu, Tray, NoIcon
#NoEnv
AutoTrim, Off
#UseHook
#MaxThreadsPerHotKey 2

SetKeyDelay, 0, 20

SplitPath, A_ScriptName,,,, vScriptNameNoExt
Menu, Tray, Tip, % vScriptNameNoExt

;==================================================

vListVisibleWindows := 1
vListCount := 4

;==================================================

hIcon := DllCall("user32\LoadIcon", Ptr,0, Ptr,32512, Ptr) ;IDI_APPLICATION := 32512
hIconDT := LoadPicture("shell32.dll", "w16 h16 icon35", vType)
hIconDTBig := LoadPicture("shell32.dll", "w32 h32 icon35", vType)

Gui, New, +HwndhGui -Caption, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, Font, s11, Consolas
Gui, Color, DEDEDE
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y230 w415 h28 vMyLabel BackgroundDEDEDE, Embossed Window
Gui, Add, ListView, x-2 y20 w480 h210 +LV0x3 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +BackgroundDEDEDE
return
 
;==================================================

GuiClose:
ExitApp
return

;==================================================

^!Tab::
vKeepOpen := true
vIndex++
if (vIndex > oHWnd.MaxIndex())
    vIndex := 1
LV_Modify(0, "-Select")
LV_Modify(vIndex, "Select Vis")
goto HandleAltTab

!Tab::
+!Tab::
vKeepOpen := false
vIndex += InStr(A_ThisHotkey, "+") ? -1 : 1

HandleAltTab:
Gui, % hGui ":Default"

if !DllCall("user32\IsWindowVisible", "Ptr",hGui)
{
    Hotkey, IfWinActive, % "ahk_id " hGui
    Hotkey, *Esc, DoCancel, On
    LV_Delete(), IL_Destroy(hIL)
    hIL := IL_Create(28, 28, 1)
    LV_SetImageList(hIL)
    vCount := 0, vPrompt := "", oHWnd := {}, oTitle := {}, oHIcon := {}, oHIconBig := {}
    Loop % vListCount
    {
        if (A_Index = vListVisibleWindows)
        {
            DetectHiddenWindows, Off
            WinGet, vWinList, List
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd[vCount] := hWnd
                oTitle[vCount] := vFileName
                oHIcon[vCount] := JEE_WinGetIcon(hWnd, 1)
                oHIconBig[vCount] := JEE_WinGetIcon(hWnd, 1)
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)
                LV_ModifyCol(1, 40)
            }

            DetectHiddenWindows, On
        }

        vDesktopFound := false

        Loop, % oHWnd.MaxIndex()
        {
            if (oTitle[A_Index] = "Desktop")
            {
                vDesktopFound := true
                break
            }
        }

        if !vDesktopFound
        {
            vCount += 1
            oHWnd[vCount] := "Desktop"
            oTitle[vCount] := "Desktop"
            oHIcon[vCount] := hIconDT
            oHIconBig[vCount] := hIconDTBig
            IL_Add(hIL, "HICON:*" oHIcon[vCount])
            LV_Add("Icon" vCount)
        }

        if (A_Index = vListIntExpTabs)
        {
            WinGet, vWinList, List, ahk_class TabThumbnailWindow
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd.Push(hWnd)
                oTitle.Push(vFileName)
                oHIcon.Push(JEE_WinGetIcon(hWnd, 1))
                oHIconBig.Push(JEE_WinGetIcon(hWnd, 1))
                ToolTip, % "Title: " oTitle[vCount] " | Icon Index: " vCount
                Sleep, 500
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)
                LV_ModifyCol(1, 40)
            }

        }
    }

    ;Loop 2
    ;    LV_Add("Icon0", "")
    ;==============================
    vIndex := 2
    WinSetRegion(hGui, 20)
    SetTimer, CheckAlt, 5
    SetTimer, HandleAltTab, 10

;---------GET CENTER OF CURRENT MONITOR---------
        ;get current monitor index
        CurrentMonitorIndex:=GetCurrentMonitorIndex()
        ;get Hwnd of current GUI
        DetectHiddenWindows On
        Gui, +LastFound
        Gui, Show, w457 h266
        GUI_Hwnd := WinExist()
        ;Calculate size of GUI
        GetClientSize(GUI_Hwnd,GUI_Width,GUI_Height)
        DetectHiddenWindows Off
        ;Calculate where the GUI should be positioned
        GUI_X:=CoordXCenterScreen(GUI_Width,CurrentMonitorIndex)
        GUI_Y:=CoordYCenterScreen(GUI_Height,CurrentMonitorIndex)

        ;------- / GET CENTER OF CURRENT MONITOR---------
        ;SHOW GUI AT CENTER OF CURRENT SCREEN
        Gui, Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Return

        GetCurrentMonitorIndex(){
        CoordMode, Mouse, Screen
        MouseGetPos, mx, my
        SysGet, monitorsCount, 80

        Loop %monitorsCount%{
            SysGet, monitor, Monitor, %A_Index%
            if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
                Return A_Index
                }
            }
            Return 1
    }

        CoordXCenterScreen(WidthOfGUI,ScreenNumber)
    {
        SysGet, Mon1, Monitor, %ScreenNumber%
        return (( Mon1Right-Mon1Left - WidthOfGUI ) / 2) + Mon1Left
    }

    CoordYCenterScreen(HeightofGUI,ScreenNumber){
        SysGet, Mon1, Monitor, %ScreenNumber%
        return ((Mon1Bottom-Mon1Top - 30 - HeightofGUI ) / 2) + Mon1Top
    }

    GetClientSize(hwnd, ByRef w, ByRef h)
    {
        VarSetCapacity(rc, 16)
        DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
        w := NumGet(rc, 8, "int")
        h := NumGet(rc, 12, "int")
    }
}

if (vIndex < 1)
    vIndex := vCount
if (vIndex > vCount)
    vIndex := 1

ControlSetText,, % oTitle[vIndex], % "ahk_id " hStc
SendMessage, 0x170, % oHIcon[vIndex], 0,, % "ahk_id " hStcImg ;STM_SETICON := 0x170

LV_Modify(0, "-Select")
LV_Modify(vIndex, "Vis")
LV_Modify(vIndex, "Select Vis")
return

;==================================================

CheckAlt:
if !GetKeyState("Alt", "P") && !vKeepOpen
{
    SetTimer, CheckAlt, Off
    SetTimer, HandleAltTab, Off
    WinHide, % "ahk_id " hGui
    DetectHiddenWindows, On
    if (oTitle[vIndex] = "Desktop")
    {
        DllCall("user32\ShowWindow", "Ptr", hGui, "Int", 0)
        WinMinimizeAll
    }
    else
    {
        WinActivate, % "ahk_id " oHWnd[vIndex]
    }
}
return

;==================================================

#If WinActive("ahk_id " hGui)

Tab::
Right::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

+Tab::
Left::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()

    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelUp::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelDown::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

Enter::
NumpadEnter::
Space::
    if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
        WinActivate, % "ahk_id " oHWnd[vIndex]
        vKeepOpen := false
        SetTimer, HandleAltTab, Off
        Gui, Hide
    }
return

Esc::
    vKeepOpen := false
    SetTimer, HandleAltTab, Off
    LV_Modify(0, "-Select")
    vIndex := 0
    Gui, Hide
return
#If

;==================================================

OnListViewClick:
    if (A_GuiEvent = "Normal") {
        LV_GetText(vSelectedTitle, A_EventInfo, 1)
        vIndex := A_EventInfo
        if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
            WinActivate, % "ahk_id " oHWnd[vIndex]
            vKeepOpen := false
            SetTimer, HandleAltTab, Off
            Gui, Hide
        }
    }
return

;==================================================

DoCancel:
SetTimer, CheckAlt, Off
Hotkey, IfWinActive, % "ahk_id " hGui
Hotkey, *Esc, DoCancel, Off
WinHide, % "ahk_id " hGui
return

;==================================================

JEE_WinGetIcon(hWnd, vDoGetBig:=0)
{
    static vSfx := (A_PtrSize=8) ? "Ptr" : ""
    if !hWnd || !WinExist("ahk_id " hWnd)
        return 0
    if vDoGetBig
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    else
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    return 0
}

;==================================================

JEE_WinHasTaskbarButton(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
    || DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    if DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
        return 0
    return 1
}

;==================================================

JEE_WinHasAltTabIcon(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
    || (vWinStyle & 0x8000000) ;WS_DISABLED := 0x8000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
    || (vWinExStyle & 0x8000000) ;WS_EX_NOACTIVATE := 0x8000000
        return 0
    return 1
}

;==================================================

WinSetRegion(hWnd, Radius := 20)
{
    hRgn := DllCall("gdi32\CreateRoundRectRgn", "Int", 0, "Int", 0, "Int", 457, "Int", 267, "Int", Radius, "Int", Radius, "Ptr")
    DllCall("user32\SetWindowRgn", "Ptr", hWnd, "Ptr", hRgn, "Int", 1)
}
 

Attachments

Last edited:

My Computer

System One

  • OS
    Windows 11 Pro
All Dark Mode Highlight EXEs are attached to post as ZIPs


1746729319727.webp

Code:
;Alt-Tab Reincarnation

#SingleInstance force
ListLines, Off
#KeyHistory 0
Menu, Tray, Click, 1
;Menu, Tray, NoIcon
#NoEnv
AutoTrim, Off
#UseHook
#MaxThreadsPerHotKey 2

SetKeyDelay, 0, 20

SplitPath, A_ScriptName,,,, vScriptNameNoExt
Menu, Tray, Tip, % vScriptNameNoExt

;==================================================

vListVisibleWindows := 1
vListCount := 4

;==================================================

hIcon := DllCall("user32\LoadIcon", Ptr,0, Ptr,32512, Ptr) ;IDI_APPLICATION := 32512
hIconDT := LoadPicture("shell32.dll", "w16 h16 icon35", vType)
hIconDTBig := LoadPicture("shell32.dll", "w32 h32 icon35", vType)

Gui, New, +HwndhGui -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, Font, s11, Consolas
Gui, Color, 242424
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y80 w415 h28 vMyLabel cWhite Background242424, Embossed Window
Gui, Add, ListView, x-2 y20 w480 h57 +LV0x3 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +Background242424
return
    
;==================================================

GuiClose:
ExitApp
return

;==================================================

^!Tab::
vKeepOpen := true
vIndex++
if (vIndex > oHWnd.MaxIndex())
    vIndex := 1
LV_Modify(0, "-Select")
LV_Modify(vIndex, "Select Vis")
goto HandleAltTab

!Tab::
+!Tab::
vKeepOpen := false
vIndex += InStr(A_ThisHotkey, "+") ? -1 : 1

HandleAltTab:
Gui, % hGui ":Default"

if !DllCall("user32\IsWindowVisible", "Ptr",hGui)
{
    Hotkey, IfWinActive, % "ahk_id " hGui
    Hotkey, *Esc, DoCancel, On
    LV_Delete(), IL_Destroy(hIL)
    hIL := IL_Create(28, 28, 1)
    LV_SetImageList(hIL)
    vCount := 0, vPrompt := "", oHWnd := {}, oTitle := {}, oHIcon := {}, oHIconBig := {}
    Loop % vListCount
    {
        if (A_Index = vListVisibleWindows)
        {
            DetectHiddenWindows, Off
            WinGet, vWinList, List
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd[vCount] := hWnd
                oTitle[vCount] := vFileName
                oHIcon[vCount] := JEE_WinGetIcon(hWnd, 1)
                oHIconBig[vCount] := JEE_WinGetIcon(hWnd, 1)
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)    
                LV_ModifyCol(1, 40)  
            }

            DetectHiddenWindows, On
        }

        vDesktopFound := false

        Loop, % oHWnd.MaxIndex()
        {
            if (oTitle[A_Index] = "Desktop")
            {
                vDesktopFound := true
                break
            }
        }

        if !vDesktopFound
        {
            vCount += 1
            oHWnd[vCount] := "Desktop"
            oTitle[vCount] := "Desktop"
            oHIcon[vCount] := hIconDT
            oHIconBig[vCount] := hIconDTBig
            IL_Add(hIL, "HICON:*" oHIcon[vCount])
            LV_Add("Icon" vCount)  
        }

        if (A_Index = vListIntExpTabs)
        {
            WinGet, vWinList, List, ahk_class TabThumbnailWindow
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd.Push(hWnd)
                oTitle.Push(vFileName)
                oHIcon.Push(JEE_WinGetIcon(hWnd, 1))
                oHIconBig.Push(JEE_WinGetIcon(hWnd, 1))
                ToolTip, % "Title: " oTitle[vCount] " | Icon Index: " vCount
                Sleep, 500
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)    
                LV_ModifyCol(1, 40)  
            }

        }
    }

    ;Loop 2
    ;    LV_Add("Icon0", "")
    ;==============================
    vIndex := 2
    SetTimer, CheckAlt, 5
    SetTimer, HandleAltTab, 10

;---------GET CENTER OF CURRENT MONITOR---------
        ;get current monitor index
        CurrentMonitorIndex:=GetCurrentMonitorIndex()
        ;get Hwnd of current GUI
        DetectHiddenWindows On
        Gui, +LastFound
        Gui, Show, w457 h122
        GUI_Hwnd := WinExist()
        ;Calculate size of GUI
        GetClientSize(GUI_Hwnd,GUI_Width,GUI_Height)
        DetectHiddenWindows Off
        ;Calculate where the GUI should be positioned
        GUI_X:=CoordXCenterScreen(GUI_Width,CurrentMonitorIndex)
        GUI_Y:=CoordYCenterScreen(GUI_Height,CurrentMonitorIndex)

        ;------- / GET CENTER OF CURRENT MONITOR--------- 
        ;SHOW GUI AT CENTER OF CURRENT SCREEN
        Gui, Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Return

        GetCurrentMonitorIndex(){
        CoordMode, Mouse, Screen
        MouseGetPos, mx, my
        SysGet, monitorsCount, 80

        Loop %monitorsCount%{
            SysGet, monitor, Monitor, %A_Index%
            if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
                Return A_Index
                }
            }
            Return 1
    }

        CoordXCenterScreen(WidthOfGUI,ScreenNumber)
    {
        SysGet, Mon1, Monitor, %ScreenNumber%
        return (( Mon1Right-Mon1Left - WidthOfGUI ) / 2) + Mon1Left
    }

    CoordYCenterScreen(HeightofGUI,ScreenNumber){
        SysGet, Mon1, Monitor, %ScreenNumber%
        return ((Mon1Bottom-Mon1Top - 30 - HeightofGUI ) / 2) + Mon1Top
    }

    GetClientSize(hwnd, ByRef w, ByRef h)
    {
        VarSetCapacity(rc, 16)
        DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
        w := NumGet(rc, 8, "int")
        h := NumGet(rc, 12, "int")
    }
}

if (vIndex < 1)
    vIndex := vCount
if (vIndex > vCount)
    vIndex := 1

ControlSetText,, % oTitle[vIndex], % "ahk_id " hStc
SendMessage, 0x170, % oHIcon[vIndex], 0,, % "ahk_id " hStcImg ;STM_SETICON := 0x170

LV_Modify(0, "-Select")
LV_Modify(vIndex, "Vis")
LV_Modify(vIndex, "Select Vis")
return

;==================================================

CheckAlt:
if !GetKeyState("Alt", "P") && !vKeepOpen
{
    SetTimer, CheckAlt, Off
    SetTimer, HandleAltTab, Off
    WinHide, % "ahk_id " hGui
    DetectHiddenWindows, On
    if (oTitle[vIndex] = "Desktop")
    {
        DllCall("user32\ShowWindow", "Ptr", hGui, "Int", 0)
        WinMinimizeAll
    }
    else 
    {
        WinActivate, % "ahk_id " oHWnd[vIndex]
    }
}
return

;==================================================

#If WinActive("ahk_id " hGui)

Tab::
Right::
    if (vIndex < vCount) 
        vIndex++
    else 
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

+Tab::
Left::
    if (vIndex > 1) 
        vIndex--
    else 
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelUp::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelDown::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

Enter::
NumpadEnter::
Space::
    if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
        WinActivate, % "ahk_id " oHWnd[vIndex]
        vKeepOpen := false
        SetTimer, HandleAltTab, Off
        Gui, Hide
    }
return

Esc::
    vKeepOpen := false
    SetTimer, HandleAltTab, Off
    LV_Modify(0, "-Select")
    vIndex := 0  
    Gui, Hide
return

#If

;==================================================

OnListViewClick:
    if (A_GuiEvent = "Normal") {
        LV_GetText(vSelectedTitle, A_EventInfo, 1)
        vIndex := A_EventInfo
        if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
            WinActivate, % "ahk_id " oHWnd[vIndex]
            vKeepOpen := false
            SetTimer, HandleAltTab, Off
            Gui, Hide
        }
    }
return

;==================================================

DoCancel:
SetTimer, CheckAlt, Off
Hotkey, IfWinActive, % "ahk_id " hGui
Hotkey, *Esc, DoCancel, Off
WinHide, % "ahk_id " hGui
return

;==================================================

JEE_WinGetIcon(hWnd, vDoGetBig:=0)
{
    static vSfx := (A_PtrSize=8) ? "Ptr" : ""
    if !hWnd || !WinExist("ahk_id " hWnd)
        return 0
    if vDoGetBig
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    else
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    return 0
}

;==================================================

JEE_WinHasTaskbarButton(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
    || DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    if DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
        return 0
    return 1
}

;==================================================

JEE_WinHasAltTabIcon(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
    || (vWinStyle & 0x8000000) ;WS_DISABLED := 0x8000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
    || (vWinExStyle & 0x8000000) ;WS_EX_NOACTIVATE := 0x8000000
        return 0
    return 1
}

;==================================================

WinSetRegion(hWnd, Radius := 20)
{
    hRgn := DllCall("gdi32\CreateRoundRectRgn", "Int", 0, "Int", 0, "Int", 457, "Int", 122, "Int", Radius, "Int", Radius, "Ptr")
    DllCall("user32\SetWindowRgn", "Ptr", hWnd, "Ptr", hRgn, "Int", 1)
}


1746729217885.webp

Code:
;Alt-Tab Reincarnation

#SingleInstance force
ListLines, Off
#KeyHistory 0
Menu, Tray, Click, 1
;Menu, Tray, NoIcon
#NoEnv
AutoTrim, Off
#UseHook
#MaxThreadsPerHotKey 2

SetKeyDelay, 0, 20

SplitPath, A_ScriptName,,,, vScriptNameNoExt
Menu, Tray, Tip, % vScriptNameNoExt

;==================================================

vListVisibleWindows := 1
vListCount := 4

;==================================================

hIcon := DllCall("user32\LoadIcon", Ptr,0, Ptr,32512, Ptr) ;IDI_APPLICATION := 32512
hIconDT := LoadPicture("shell32.dll", "w16 h16 icon35", vType)
hIconDTBig := LoadPicture("shell32.dll", "w32 h32 icon35", vType)

Gui, New, +HwndhGui -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, Font, s11, Consolas
Gui, Color, 242424
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y80 w415 h28 vMyLabel cWhite Background242424, Embossed Window
Gui, Add, ListView, x-2 y20 w480 h57 +LV0x3 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +Background242424
return
    
;==================================================

GuiClose:
ExitApp
return

;==================================================

^!Tab::
vKeepOpen := true
vIndex++
if (vIndex > oHWnd.MaxIndex())
    vIndex := 1
LV_Modify(0, "-Select")
LV_Modify(vIndex, "Select Vis")
goto HandleAltTab

!Tab::
+!Tab::
vKeepOpen := false
vIndex += InStr(A_ThisHotkey, "+") ? -1 : 1

HandleAltTab:
Gui, % hGui ":Default"

if !DllCall("user32\IsWindowVisible", "Ptr",hGui)
{
    Hotkey, IfWinActive, % "ahk_id " hGui
    Hotkey, *Esc, DoCancel, On
    LV_Delete(), IL_Destroy(hIL)
    hIL := IL_Create(28, 28, 1)
    LV_SetImageList(hIL)
    vCount := 0, vPrompt := "", oHWnd := {}, oTitle := {}, oHIcon := {}, oHIconBig := {}
    Loop % vListCount
    {
        if (A_Index = vListVisibleWindows)
        {
            DetectHiddenWindows, Off
            WinGet, vWinList, List
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd[vCount] := hWnd
                oTitle[vCount] := vFileName
                oHIcon[vCount] := JEE_WinGetIcon(hWnd, 1)
                oHIconBig[vCount] := JEE_WinGetIcon(hWnd, 1)
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)    
                LV_ModifyCol(1, 40)  
            }

            DetectHiddenWindows, On
        }

        vDesktopFound := false

        Loop, % oHWnd.MaxIndex()
        {
            if (oTitle[A_Index] = "Desktop")
            {
                vDesktopFound := true
                break
            }
        }

        if !vDesktopFound
        {
            vCount += 1
            oHWnd[vCount] := "Desktop"
            oTitle[vCount] := "Desktop"
            oHIcon[vCount] := hIconDT
            oHIconBig[vCount] := hIconDTBig
            IL_Add(hIL, "HICON:*" oHIcon[vCount])
            LV_Add("Icon" vCount)  
        }

        if (A_Index = vListIntExpTabs)
        {
            WinGet, vWinList, List, ahk_class TabThumbnailWindow
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd.Push(hWnd)
                oTitle.Push(vFileName)
                oHIcon.Push(JEE_WinGetIcon(hWnd, 1))
                oHIconBig.Push(JEE_WinGetIcon(hWnd, 1))
                ToolTip, % "Title: " oTitle[vCount] " | Icon Index: " vCount
                Sleep, 500
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)    
                LV_ModifyCol(1, 40)  
            }

        }
    }

    ;Loop 2
    ;    LV_Add("Icon0", "")
    ;==============================
    vIndex := 2
    WinSetRegion(hGui, 20)
    SetTimer, CheckAlt, 5
    SetTimer, HandleAltTab, 10

;---------GET CENTER OF CURRENT MONITOR---------
        ;get current monitor index
        CurrentMonitorIndex:=GetCurrentMonitorIndex()
        ;get Hwnd of current GUI
        DetectHiddenWindows On
        Gui, +LastFound
        Gui, Show, w457 h122
        GUI_Hwnd := WinExist()
        ;Calculate size of GUI
        GetClientSize(GUI_Hwnd,GUI_Width,GUI_Height)
        DetectHiddenWindows Off
        ;Calculate where the GUI should be positioned
        GUI_X:=CoordXCenterScreen(GUI_Width,CurrentMonitorIndex)
        GUI_Y:=CoordYCenterScreen(GUI_Height,CurrentMonitorIndex)

        ;------- / GET CENTER OF CURRENT MONITOR--------- 
        ;SHOW GUI AT CENTER OF CURRENT SCREEN
        Gui, Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Return

        GetCurrentMonitorIndex(){
        CoordMode, Mouse, Screen
        MouseGetPos, mx, my
        SysGet, monitorsCount, 80

        Loop %monitorsCount%{
            SysGet, monitor, Monitor, %A_Index%
            if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
                Return A_Index
                }
            }
            Return 1
    }

        CoordXCenterScreen(WidthOfGUI,ScreenNumber)
    {
        SysGet, Mon1, Monitor, %ScreenNumber%
        return (( Mon1Right-Mon1Left - WidthOfGUI ) / 2) + Mon1Left
    }

    CoordYCenterScreen(HeightofGUI,ScreenNumber){
        SysGet, Mon1, Monitor, %ScreenNumber%
        return ((Mon1Bottom-Mon1Top - 30 - HeightofGUI ) / 2) + Mon1Top
    }

    GetClientSize(hwnd, ByRef w, ByRef h)
    {
        VarSetCapacity(rc, 16)
        DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
        w := NumGet(rc, 8, "int")
        h := NumGet(rc, 12, "int")
    }
}

if (vIndex < 1)
    vIndex := vCount
if (vIndex > vCount)
    vIndex := 1

ControlSetText,, % oTitle[vIndex], % "ahk_id " hStc
SendMessage, 0x170, % oHIcon[vIndex], 0,, % "ahk_id " hStcImg ;STM_SETICON := 0x170

LV_Modify(0, "-Select")
LV_Modify(vIndex, "Vis")
LV_Modify(vIndex, "Select Vis")
return

;==================================================

CheckAlt:
if !GetKeyState("Alt", "P") && !vKeepOpen
{
    SetTimer, CheckAlt, Off
    SetTimer, HandleAltTab, Off
    WinHide, % "ahk_id " hGui
    DetectHiddenWindows, On
    if (oTitle[vIndex] = "Desktop")
    {
        DllCall("user32\ShowWindow", "Ptr", hGui, "Int", 0)
        WinMinimizeAll
    }
    else 
    {
        WinActivate, % "ahk_id " oHWnd[vIndex]
    }
}
return

;==================================================

#If WinActive("ahk_id " hGui)

Tab::
Right::
    if (vIndex < vCount) 
        vIndex++
    else 
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

+Tab::
Left::
    if (vIndex > 1) 
        vIndex--
    else 
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelUp::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelDown::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

Enter::
NumpadEnter::
Space::
    if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
        WinActivate, % "ahk_id " oHWnd[vIndex]
        vKeepOpen := false
        SetTimer, HandleAltTab, Off
        Gui, Hide
    }
return

Esc::
    vKeepOpen := false
    SetTimer, HandleAltTab, Off
    LV_Modify(0, "-Select")
    vIndex := 0  
    Gui, Hide
return

#If

;==================================================

OnListViewClick:
    if (A_GuiEvent = "Normal") {
        LV_GetText(vSelectedTitle, A_EventInfo, 1)
        vIndex := A_EventInfo
        if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
            WinActivate, % "ahk_id " oHWnd[vIndex]
            vKeepOpen := false
            SetTimer, HandleAltTab, Off
            Gui, Hide
        }
    }
return

;==================================================

DoCancel:
SetTimer, CheckAlt, Off
Hotkey, IfWinActive, % "ahk_id " hGui
Hotkey, *Esc, DoCancel, Off
WinHide, % "ahk_id " hGui
return

;==================================================

JEE_WinGetIcon(hWnd, vDoGetBig:=0)
{
    static vSfx := (A_PtrSize=8) ? "Ptr" : ""
    if !hWnd || !WinExist("ahk_id " hWnd)
        return 0
    if vDoGetBig
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    else
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    return 0
}

;==================================================

JEE_WinHasTaskbarButton(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
    || DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    if DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
        return 0
    return 1
}

;==================================================

JEE_WinHasAltTabIcon(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
    || (vWinStyle & 0x8000000) ;WS_DISABLED := 0x8000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
    || (vWinExStyle & 0x8000000) ;WS_EX_NOACTIVATE := 0x8000000
        return 0
    return 1
}

;==================================================

WinSetRegion(hWnd, Radius := 20)
{
    hRgn := DllCall("gdi32\CreateRoundRectRgn", "Int", 0, "Int", 0, "Int", 457, "Int", 122, "Int", Radius, "Int", Radius, "Ptr")
    DllCall("user32\SetWindowRgn", "Ptr", hWnd, "Ptr", hRgn, "Int", 1)
}


1746729374657.webp

Code:
;Alt-Tab Reincarnation

#SingleInstance force
ListLines, Off
#KeyHistory 0
Menu, Tray, Click, 1
;Menu, Tray, NoIcon
#NoEnv
AutoTrim, Off
#UseHook
#MaxThreadsPerHotKey 2

SetKeyDelay, 0, 20

SplitPath, A_ScriptName,,,, vScriptNameNoExt
Menu, Tray, Tip, % vScriptNameNoExt

;==================================================

vListVisibleWindows := 1
vListCount := 4

;==================================================

hIcon := DllCall("user32\LoadIcon", Ptr,0, Ptr,32512, Ptr) ;IDI_APPLICATION := 32512
hIconDT := LoadPicture("shell32.dll", "w16 h16 icon35", vType)
hIconDTBig := LoadPicture("shell32.dll", "w32 h32 icon35", vType)

Gui, New, +HwndhGui -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, Font, s11, Consolas
Gui, Color, 242424
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y230 w415 h28 vMyLabel cWhite, +Background242424, Embossed Window
Gui, Add, ListView, x-2 y20 w480 h210 +LV0x3 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +Background242424
return
    
;==================================================

GuiClose:
ExitApp
return

;==================================================

^!Tab::
vKeepOpen := true
vIndex++
if (vIndex > oHWnd.MaxIndex())
    vIndex := 1
LV_Modify(0, "-Select")
LV_Modify(vIndex, "Select Vis")
goto HandleAltTab

!Tab::
+!Tab::
vKeepOpen := false
vIndex += InStr(A_ThisHotkey, "+") ? -1 : 1

HandleAltTab:
Gui, % hGui ":Default"

if !DllCall("user32\IsWindowVisible", "Ptr",hGui)
{
    Hotkey, IfWinActive, % "ahk_id " hGui
    Hotkey, *Esc, DoCancel, On
    LV_Delete(), IL_Destroy(hIL)
    hIL := IL_Create(28, 28, 1)
    LV_SetImageList(hIL)
    vCount := 0, vPrompt := "", oHWnd := {}, oTitle := {}, oHIcon := {}, oHIconBig := {}
    Loop % vListCount
    {
        if (A_Index = vListVisibleWindows)
        {
            DetectHiddenWindows, Off
            WinGet, vWinList, List
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd[vCount] := hWnd
                oTitle[vCount] := vFileName
                oHIcon[vCount] := JEE_WinGetIcon(hWnd, 1)
                oHIconBig[vCount] := JEE_WinGetIcon(hWnd, 1)
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)    
                LV_ModifyCol(1, 40)  
            }

            DetectHiddenWindows, On
        }

        vDesktopFound := false

        Loop, % oHWnd.MaxIndex()
        {
            if (oTitle[A_Index] = "Desktop")
            {
                vDesktopFound := true
                break
            }
        }

        if !vDesktopFound
        {
            vCount += 1
            oHWnd[vCount] := "Desktop"
            oTitle[vCount] := "Desktop"
            oHIcon[vCount] := hIconDT
            oHIconBig[vCount] := hIconDTBig
            IL_Add(hIL, "HICON:*" oHIcon[vCount])
            LV_Add("Icon" vCount)  
        }

        if (A_Index = vListIntExpTabs)
        {
            WinGet, vWinList, List, ahk_class TabThumbnailWindow
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd.Push(hWnd)
                oTitle.Push(vFileName)
                oHIcon.Push(JEE_WinGetIcon(hWnd, 1))
                oHIconBig.Push(JEE_WinGetIcon(hWnd, 1))
                ToolTip, % "Title: " oTitle[vCount] " | Icon Index: " vCount
                Sleep, 500
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)    
                LV_ModifyCol(1, 40)  
            }

        }
    }

    ;Loop 2
    ;    LV_Add("Icon0", "")
    ;==============================
    vIndex := 2
    SetTimer, CheckAlt, 5
    SetTimer, HandleAltTab, 10

;---------GET CENTER OF CURRENT MONITOR---------
        ;get current monitor index
        CurrentMonitorIndex:=GetCurrentMonitorIndex()
        ;get Hwnd of current GUI
        DetectHiddenWindows On
        Gui, +LastFound
        Gui, Show, w457 h271
        GUI_Hwnd := WinExist()
        ;Calculate size of GUI
        GetClientSize(GUI_Hwnd,GUI_Width,GUI_Height)
        DetectHiddenWindows Off
        ;Calculate where the GUI should be positioned
        GUI_X:=CoordXCenterScreen(GUI_Width,CurrentMonitorIndex)
        GUI_Y:=CoordYCenterScreen(GUI_Height,CurrentMonitorIndex)

        ;------- / GET CENTER OF CURRENT MONITOR--------- 
        ;SHOW GUI AT CENTER OF CURRENT SCREEN
        Gui, Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Return

        GetCurrentMonitorIndex(){
        CoordMode, Mouse, Screen
        MouseGetPos, mx, my
        SysGet, monitorsCount, 80

        Loop %monitorsCount%{
            SysGet, monitor, Monitor, %A_Index%
            if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
                Return A_Index
                }
            }
            Return 1
    }

        CoordXCenterScreen(WidthOfGUI,ScreenNumber)
    {
        SysGet, Mon1, Monitor, %ScreenNumber%
        return (( Mon1Right-Mon1Left - WidthOfGUI ) / 2) + Mon1Left
    }

    CoordYCenterScreen(HeightofGUI,ScreenNumber){
        SysGet, Mon1, Monitor, %ScreenNumber%
        return ((Mon1Bottom-Mon1Top - 30 - HeightofGUI ) / 2) + Mon1Top
    }

    GetClientSize(hwnd, ByRef w, ByRef h)
    {
        VarSetCapacity(rc, 16)
        DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
        w := NumGet(rc, 8, "int")
        h := NumGet(rc, 12, "int")
    }
}

if (vIndex < 1)
    vIndex := vCount
if (vIndex > vCount)
    vIndex := 1

ControlSetText,, % oTitle[vIndex], % "ahk_id " hStc
SendMessage, 0x170, % oHIcon[vIndex], 0,, % "ahk_id " hStcImg ;STM_SETICON := 0x170

LV_Modify(0, "-Select")
LV_Modify(vIndex, "Vis")
LV_Modify(vIndex, "Select Vis")
return

;==================================================

CheckAlt:
if !GetKeyState("Alt", "P") && !vKeepOpen
{
    SetTimer, CheckAlt, Off
    SetTimer, HandleAltTab, Off
    WinHide, % "ahk_id " hGui
    DetectHiddenWindows, On
    if (oTitle[vIndex] = "Desktop")
    {
        DllCall("user32\ShowWindow", "Ptr", hGui, "Int", 0)
        WinMinimizeAll
    }
    else 
    {
        WinActivate, % "ahk_id " oHWnd[vIndex]
    }
}
return

;==================================================

#If WinActive("ahk_id " hGui)

Tab::
Right::
    if (vIndex < vCount) 
        vIndex++
    else 
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

+Tab::
Left::
    if (vIndex > 1) 
        vIndex--
    else 
        vIndex := oHWnd.MaxIndex()

    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelUp::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelDown::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

Enter::
NumpadEnter::
Space::
    if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
        WinActivate, % "ahk_id " oHWnd[vIndex]
        vKeepOpen := false
        SetTimer, HandleAltTab, Off
        Gui, Hide
    }
return

Esc::
    vKeepOpen := false
    SetTimer, HandleAltTab, Off
    LV_Modify(0, "-Select")
    vIndex := 0  
    Gui, Hide
return
#If

;==================================================

OnListViewClick:
    if (A_GuiEvent = "Normal") {
        LV_GetText(vSelectedTitle, A_EventInfo, 1)
        vIndex := A_EventInfo
        if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
            WinActivate, % "ahk_id " oHWnd[vIndex]
            vKeepOpen := false
            SetTimer, HandleAltTab, Off
            Gui, Hide
        }
    }
return

;==================================================

DoCancel:
SetTimer, CheckAlt, Off
Hotkey, IfWinActive, % "ahk_id " hGui
Hotkey, *Esc, DoCancel, Off
WinHide, % "ahk_id " hGui
return

;==================================================

JEE_WinGetIcon(hWnd, vDoGetBig:=0)
{
    static vSfx := (A_PtrSize=8) ? "Ptr" : ""
    if !hWnd || !WinExist("ahk_id " hWnd)
        return 0
    if vDoGetBig
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    else
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    return 0
}

;==================================================

JEE_WinHasTaskbarButton(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
    || DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    if DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
        return 0
    return 1
}

;==================================================

JEE_WinHasAltTabIcon(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
    || (vWinStyle & 0x8000000) ;WS_DISABLED := 0x8000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
    || (vWinExStyle & 0x8000000) ;WS_EX_NOACTIVATE := 0x8000000
        return 0
    return 1
}

;==================================================

WinSetRegion(hWnd, Radius := 20)
{
    hRgn := DllCall("gdi32\CreateRoundRectRgn", "Int", 0, "Int", 0, "Int", 457, "Int", 271, "Int", Radius, "Int", Radius, "Ptr")
    DllCall("user32\SetWindowRgn", "Ptr", hWnd, "Ptr", hRgn, "Int", 1)
}


1746729270450.webp

Code:
;Alt-Tab Reincarnation

#SingleInstance force
ListLines, Off
#KeyHistory 0
Menu, Tray, Click, 1
;Menu, Tray, NoIcon
#NoEnv
AutoTrim, Off
#UseHook
#MaxThreadsPerHotKey 2

SetKeyDelay, 0, 20

SplitPath, A_ScriptName,,,, vScriptNameNoExt
Menu, Tray, Tip, % vScriptNameNoExt

;==================================================

vListVisibleWindows := 1
vListCount := 4

;==================================================

hIcon := DllCall("user32\LoadIcon", Ptr,0, Ptr,32512, Ptr) ;IDI_APPLICATION := 32512
hIconDT := LoadPicture("shell32.dll", "w16 h16 icon35", vType)
hIconDTBig := LoadPicture("shell32.dll", "w32 h32 icon35", vType)

Gui, New, +HwndhGui -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, Font, s11, Consolas
Gui, Color, 242424
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y230 w415 h28 vMyLabel cWhite, +Background242424, Embossed Window
Gui, Add, ListView, x-2 y20 w480 h210 +LV0x3 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +Background242424
return
    
;==================================================

GuiClose:
ExitApp
return

;==================================================

^!Tab::
vKeepOpen := true
vIndex++
if (vIndex > oHWnd.MaxIndex())
    vIndex := 1
LV_Modify(0, "-Select")
LV_Modify(vIndex, "Select Vis")
goto HandleAltTab

!Tab::
+!Tab::
vKeepOpen := false
vIndex += InStr(A_ThisHotkey, "+") ? -1 : 1

HandleAltTab:
Gui, % hGui ":Default"

if !DllCall("user32\IsWindowVisible", "Ptr",hGui)
{
    Hotkey, IfWinActive, % "ahk_id " hGui
    Hotkey, *Esc, DoCancel, On
    LV_Delete(), IL_Destroy(hIL)
    hIL := IL_Create(28, 28, 1)
    LV_SetImageList(hIL)
    vCount := 0, vPrompt := "", oHWnd := {}, oTitle := {}, oHIcon := {}, oHIconBig := {}
    Loop % vListCount
    {
        if (A_Index = vListVisibleWindows)
        {
            DetectHiddenWindows, Off
            WinGet, vWinList, List
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd[vCount] := hWnd
                oTitle[vCount] := vFileName
                oHIcon[vCount] := JEE_WinGetIcon(hWnd, 1)
                oHIconBig[vCount] := JEE_WinGetIcon(hWnd, 1)
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)    
                LV_ModifyCol(1, 40)  
            }

            DetectHiddenWindows, On
        }

        vDesktopFound := false

        Loop, % oHWnd.MaxIndex()
        {
            if (oTitle[A_Index] = "Desktop")
            {
                vDesktopFound := true
                break
            }
        }

        if !vDesktopFound
        {
            vCount += 1
            oHWnd[vCount] := "Desktop"
            oTitle[vCount] := "Desktop"
            oHIcon[vCount] := hIconDT
            oHIconBig[vCount] := hIconDTBig
            IL_Add(hIL, "HICON:*" oHIcon[vCount])
            LV_Add("Icon" vCount)  
        }

        if (A_Index = vListIntExpTabs)
        {
            WinGet, vWinList, List, ahk_class TabThumbnailWindow
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd.Push(hWnd)
                oTitle.Push(vFileName)
                oHIcon.Push(JEE_WinGetIcon(hWnd, 1))
                oHIconBig.Push(JEE_WinGetIcon(hWnd, 1))
                ToolTip, % "Title: " oTitle[vCount] " | Icon Index: " vCount
                Sleep, 500
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)    
                LV_ModifyCol(1, 40)  
            }

        }
    }

    ;Loop 2
    ;    LV_Add("Icon0", "")
    ;==============================
    vIndex := 2
    WinSetRegion(hGui, 20)
    SetTimer, CheckAlt, 5
    SetTimer, HandleAltTab, 10

;---------GET CENTER OF CURRENT MONITOR---------
        ;get current monitor index
        CurrentMonitorIndex:=GetCurrentMonitorIndex()
        ;get Hwnd of current GUI
        DetectHiddenWindows On
        Gui, +LastFound
        Gui, Show, w457 h271
        GUI_Hwnd := WinExist()
        ;Calculate size of GUI
        GetClientSize(GUI_Hwnd,GUI_Width,GUI_Height)
        DetectHiddenWindows Off
        ;Calculate where the GUI should be positioned
        GUI_X:=CoordXCenterScreen(GUI_Width,CurrentMonitorIndex)
        GUI_Y:=CoordYCenterScreen(GUI_Height,CurrentMonitorIndex)

        ;------- / GET CENTER OF CURRENT MONITOR--------- 
        ;SHOW GUI AT CENTER OF CURRENT SCREEN
        Gui, Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Return

        GetCurrentMonitorIndex(){
        CoordMode, Mouse, Screen
        MouseGetPos, mx, my
        SysGet, monitorsCount, 80

        Loop %monitorsCount%{
            SysGet, monitor, Monitor, %A_Index%
            if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
                Return A_Index
                }
            }
            Return 1
    }

        CoordXCenterScreen(WidthOfGUI,ScreenNumber)
    {
        SysGet, Mon1, Monitor, %ScreenNumber%
        return (( Mon1Right-Mon1Left - WidthOfGUI ) / 2) + Mon1Left
    }

    CoordYCenterScreen(HeightofGUI,ScreenNumber){
        SysGet, Mon1, Monitor, %ScreenNumber%
        return ((Mon1Bottom-Mon1Top - 30 - HeightofGUI ) / 2) + Mon1Top
    }

    GetClientSize(hwnd, ByRef w, ByRef h)
    {
        VarSetCapacity(rc, 16)
        DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
        w := NumGet(rc, 8, "int")
        h := NumGet(rc, 12, "int")
    }
}

if (vIndex < 1)
    vIndex := vCount
if (vIndex > vCount)
    vIndex := 1

ControlSetText,, % oTitle[vIndex], % "ahk_id " hStc
SendMessage, 0x170, % oHIcon[vIndex], 0,, % "ahk_id " hStcImg ;STM_SETICON := 0x170

LV_Modify(0, "-Select")
LV_Modify(vIndex, "Vis")
LV_Modify(vIndex, "Select Vis")
return

;==================================================

CheckAlt:
if !GetKeyState("Alt", "P") && !vKeepOpen
{
    SetTimer, CheckAlt, Off
    SetTimer, HandleAltTab, Off
    WinHide, % "ahk_id " hGui
    DetectHiddenWindows, On
    if (oTitle[vIndex] = "Desktop")
    {
        DllCall("user32\ShowWindow", "Ptr", hGui, "Int", 0)
        WinMinimizeAll
    }
    else 
    {
        WinActivate, % "ahk_id " oHWnd[vIndex]
    }
}
return

;==================================================

#If WinActive("ahk_id " hGui)

Tab::
Right::
    if (vIndex < vCount) 
        vIndex++
    else 
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

+Tab::
Left::
    if (vIndex > 1) 
        vIndex--
    else 
        vIndex := oHWnd.MaxIndex()

    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelUp::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelDown::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

Enter::
NumpadEnter::
Space::
    if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
        WinActivate, % "ahk_id " oHWnd[vIndex]
        vKeepOpen := false
        SetTimer, HandleAltTab, Off
        Gui, Hide
    }
return

Esc::
    vKeepOpen := false
    SetTimer, HandleAltTab, Off
    LV_Modify(0, "-Select")
    vIndex := 0  
    Gui, Hide
return
#If

;==================================================

OnListViewClick:
    if (A_GuiEvent = "Normal") {
        LV_GetText(vSelectedTitle, A_EventInfo, 1)
        vIndex := A_EventInfo
        if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
            WinActivate, % "ahk_id " oHWnd[vIndex]
            vKeepOpen := false
            SetTimer, HandleAltTab, Off
            Gui, Hide
        }
    }
return

;==================================================

DoCancel:
SetTimer, CheckAlt, Off
Hotkey, IfWinActive, % "ahk_id " hGui
Hotkey, *Esc, DoCancel, Off
WinHide, % "ahk_id " hGui
return

;==================================================

JEE_WinGetIcon(hWnd, vDoGetBig:=0)
{
    static vSfx := (A_PtrSize=8) ? "Ptr" : ""
    if !hWnd || !WinExist("ahk_id " hWnd)
        return 0
    if vDoGetBig
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    else
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    return 0
}

;==================================================

JEE_WinHasTaskbarButton(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
    || DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    if DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
        return 0
    return 1
}

;==================================================

JEE_WinHasAltTabIcon(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
    || (vWinStyle & 0x8000000) ;WS_DISABLED := 0x8000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
    || (vWinExStyle & 0x8000000) ;WS_EX_NOACTIVATE := 0x8000000
        return 0
    return 1
}

;==================================================

WinSetRegion(hWnd, Radius := 20)
{
    hRgn := DllCall("gdi32\CreateRoundRectRgn", "Int", 0, "Int", 0, "Int", 457, "Int", 271, "Int", Radius, "Int", Radius, "Ptr")
    DllCall("user32\SetWindowRgn", "Ptr", hWnd, "Ptr", hRgn, "Int", 1)
}
 

Attachments

Last edited:

My Computer

System One

  • OS
    Windows 11 Pro
I am searching Classic Alt Tab for Windows 11 Home and Windows 11 Pro for a long time. After 24H2 update, old methods on web are not working any more. Your message makes me excited. But, I have no knowledge about Python. How can I run it on my Windows 11 Home?
 

My Computer

System One

  • OS
    Windows 11 Home
    Computer type
    Laptop
All Dark Mode Hottrack EXEs are attached to post as ZIPs

1746729702360.webp


Code:
;Alt-Tab Reincarnation

#SingleInstance force
ListLines, Off
#KeyHistory 0
Menu, Tray, Click, 1
;Menu, Tray, NoIcon
#NoEnv
AutoTrim, Off
#UseHook
#MaxThreadsPerHotKey 2

SetKeyDelay, 0, 20

SplitPath, A_ScriptName,,,, vScriptNameNoExt
Menu, Tray, Tip, % vScriptNameNoExt

;==================================================

vListVisibleWindows := 1
vListCount := 4

;==================================================

hIcon := DllCall("user32\LoadIcon", Ptr,0, Ptr,32512, Ptr) ;IDI_APPLICATION := 32512
hIconDT := LoadPicture("shell32.dll", "w16 h16 icon35", vType)
hIconDTBig := LoadPicture("shell32.dll", "w32 h32 icon35", vType)

Gui, 2:New, +HwndhGui2 -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, 2:Color, 242424
Gui, 2:Font, s11, Consolas
Gui, 2:Add, ListView, x-2 y20 w480 h60 +LV0x3 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +Background242424

Gui, New, +HwndhGui -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, Font, s11, Consolas
Gui, Color, 242424
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y80 w415 h28 vMyLabel cWhite Background242424, Embossed Window
Gui, Add, ListView, x-2 y20 w480 h57 +LV0x3 +LV0x8000 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +Background242424
return
  
;==================================================

GuiClose:
Gui, 2:Hide
ExitApp
return

;==================================================

^!Tab::
vKeepOpen := true
vIndex++
if (vIndex > oHWnd.MaxIndex())
    vIndex := 1
LV_Modify(0, "-Select")
LV_Modify(vIndex, "Select Vis")
goto HandleAltTab

!Tab::
+!Tab::
vKeepOpen := false
vIndex += InStr(A_ThisHotkey, "+") ? -1 : 1

HandleAltTab:
Gui, % hGui2 ":Default"
Gui, % hGui ":Default"

if !DllCall("user32\IsWindowVisible", "Ptr",hGui2)
if !DllCall("user32\IsWindowVisible", "Ptr",hGui)
{
    Hotkey, IfWinActive, % "ahk_id " hGui2
    Hotkey, IfWinActive, % "ahk_id " hGui
    Hotkey, *Esc, DoCancel, On
    LV_Delete(), IL_Destroy(hIL)
    hIL := IL_Create(28, 28, 1)
    LV_SetImageList(hIL)
    vCount := 0, vPrompt := "", oHWnd := {}, oTitle := {}, oHIcon := {}, oHIconBig := {}
    Loop % vListCount
    {
        if (A_Index = vListVisibleWindows)
        {
            DetectHiddenWindows, Off
            WinGet, vWinList, List
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd[vCount] := hWnd
                oTitle[vCount] := vFileName
                oHIcon[vCount] := JEE_WinGetIcon(hWnd, 1)
                oHIconBig[vCount] := JEE_WinGetIcon(hWnd, 1)
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)  
                LV_ModifyCol(1, 40)
            }

            DetectHiddenWindows, On
        }

        vDesktopFound := false

        Loop, % oHWnd.MaxIndex()
        {
            if (oTitle[A_Index] = "Desktop")
            {
                vDesktopFound := true
                break
            }
        }

        if !vDesktopFound
        {
            vCount += 1
            oHWnd[vCount] := "Desktop"
            oTitle[vCount] := "Desktop"
            oHIcon[vCount] := hIconDT
            oHIconBig[vCount] := hIconDTBig
            IL_Add(hIL, "HICON:*" oHIcon[vCount])
            LV_Add("Icon" vCount)
        }

        if (A_Index = vListIntExpTabs)
        {
            WinGet, vWinList, List, ahk_class TabThumbnailWindow
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd.Push(hWnd)
                oTitle.Push(vFileName)
                oHIcon.Push(JEE_WinGetIcon(hWnd, 1))
                oHIconBig.Push(JEE_WinGetIcon(hWnd, 1))
                ToolTip, % "Title: " oTitle[vCount] " | Icon Index: " vCount
                Sleep, 500
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)  
                LV_ModifyCol(1, 40)
            }

        }
    }

    ;Loop 2
    ;    LV_Add("Icon0", "")
    ;==============================
    vIndex := 2
    SetTimer, CheckAlt, 5
    SetTimer, HandleAltTab, 10

;---------GET CENTER OF CURRENT MONITOR---------
        ;get current monitor index
        CurrentMonitorIndex:=GetCurrentMonitorIndex()
        ;get Hwnd of current GUI
        DetectHiddenWindows On
        Gui, 2:Show, w457 H117
        Gui, +LastFound
        WinSet, TransColor, F0F0F0
        Gui, Show, w457 h122
        GUI_Hwnd := WinExist()
        ;Calculate size of GUI
        GetClientSize(GUI_Hwnd,GUI_Width,GUI_Height)
        DetectHiddenWindows Off
        ;Calculate where the GUI should be positioned
        GUI_X:=CoordXCenterScreen(GUI_Width,CurrentMonitorIndex)
        GUI_Y:=CoordYCenterScreen(GUI_Height,CurrentMonitorIndex)

        ;------- / GET CENTER OF CURRENT MONITOR---------
        ;SHOW GUI AT CENTER OF CURRENT SCREEN
        Gui, 2:Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Gui, Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Return

        GetCurrentMonitorIndex(){
        CoordMode, Mouse, Screen
        MouseGetPos, mx, my
        SysGet, monitorsCount, 80

        Loop %monitorsCount%{
            SysGet, monitor, Monitor, %A_Index%
            if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
                Return A_Index
                }
            }
            Return 1
    }

        CoordXCenterScreen(WidthOfGUI,ScreenNumber)
    {
        SysGet, Mon1, Monitor, %ScreenNumber%
        return (( Mon1Right-Mon1Left - WidthOfGUI ) / 2) + Mon1Left
    }

    CoordYCenterScreen(HeightofGUI,ScreenNumber){
        SysGet, Mon1, Monitor, %ScreenNumber%
        return ((Mon1Bottom-Mon1Top - 30 - HeightofGUI ) / 2) + Mon1Top
    }

    GetClientSize(hwnd, ByRef w, ByRef h)
    {
        VarSetCapacity(rc, 16)
        DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
        w := NumGet(rc, 8, "int")
        h := NumGet(rc, 12, "int")
    }  
}

if (vIndex < 1)
    vIndex := vCount
if (vIndex > vCount)
    vIndex := 1

ControlSetText,, % oTitle[vIndex], % "ahk_id " hStc
SendMessage, 0x170, % oHIcon[vIndex], 0,, % "ahk_id " hStcImg ;STM_SETICON := 0x170

LV_Modify(0, "-Select")
LV_Modify(vIndex, "Vis")
LV_Modify(vIndex, "Select Vis")
return

;==================================================

CheckAlt:
if !GetKeyState("Alt", "P") && !vKeepOpen
{
    SetTimer, CheckAlt, Off
    SetTimer, HandleAltTab, Off
    if WinExist("ahk_id " hGui) {
        WinHide, ahk_id %hGui%
        if WinExist("ahk_id " hGui2)
            WinHide, ahk_id %hGui2%
    }
    DetectHiddenWindows, On
    if (oTitle[vIndex] = "Desktop")
    {
        DllCall("user32\ShowWindow", "Ptr", hGui2, "Int", 0)
        DllCall("user32\ShowWindow", "Ptr", hGui, "Int", 0)
        WinMinimizeAll
    }
    else
    {
        WinActivate, % "ahk_id " oHWnd[vIndex]
    }
}
return

;==================================================

#If WinActive("ahk_id " hGui2)
#If WinActive("ahk_id " hGui)

Tab::
Right::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

+Tab::
Left::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelUp::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelDown::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

Enter::
NumpadEnter::
Space::
    if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
        WinActivate, % "ahk_id " oHWnd[vIndex]
        vKeepOpen := false
        SetTimer, HandleAltTab, Off
        Gui, 2:Hide
        Gui, Hide
    }
return

Esc::
    vKeepOpen := false
    SetTimer, HandleAltTab, Off
    LV_Modify(0, "-Select")
    vIndex := 0
    Gui, 2:Hide
    Gui, Hide
return
#If

;==================================================

OnListViewClick:
    if (A_GuiEvent = "Normal") {
        LV_GetText(vSelectedTitle, A_EventInfo, 1)
        vIndex := A_EventInfo
        if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
            WinActivate, % "ahk_id " oHWnd[vIndex]
            vKeepOpen := false
            SetTimer, HandleAltTab, Off
            Gui, 2:Hide
            Gui, Hide
        }
    }
return

;==================================================

DoCancel:
SetTimer, CheckAlt, Off
Hotkey, IfWinActive, % "ahk_id " hGui2
Hotkey, IfWinActive, % "ahk_id " hGui
Hotkey, *Esc, DoCancel, Off
WinHide, % "ahk_id " hGui2
WinHide, % "ahk_id " hGui
return

;==================================================

JEE_WinGetIcon(hWnd, vDoGetBig:=0)
{
    static vSfx := (A_PtrSize=8) ? "Ptr" : ""
    if !hWnd || !WinExist("ahk_id " hWnd)
        return 0
    if vDoGetBig
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    else
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    return 0
}

;==================================================

JEE_WinHasTaskbarButton(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
    || DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    if DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
        return 0
    return 1
}

;==================================================

JEE_WinHasAltTabIcon(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
    || (vWinStyle & 0x8000000) ;WS_DISABLED := 0x8000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
    || (vWinExStyle & 0x8000000) ;WS_EX_NOACTIVATE := 0x8000000
        return 0
    return 1
}

;==================================================

WinSetRegion(hWnd, Radius := 20)
{
    hRgn := DllCall("gdi32\CreateRoundRectRgn", "Int", 0, "Int", 0, "Int", 457, "Int", 122, "Int", Radius, "Int", Radius, "Ptr")
    DllCall("user32\SetWindowRgn", "Ptr", hWnd, "Ptr", hRgn, "Int", 1)
}


1746729781415.webp

Code:
;Alt-Tab Reincarnation

#SingleInstance force
ListLines, Off
#KeyHistory 0
Menu, Tray, Click, 1
;Menu, Tray, NoIcon
#NoEnv
AutoTrim, Off
#UseHook
#MaxThreadsPerHotKey 2

SetKeyDelay, 0, 20

SplitPath, A_ScriptName,,,, vScriptNameNoExt
Menu, Tray, Tip, % vScriptNameNoExt

;==================================================

vListVisibleWindows := 1
vListCount := 4

;==================================================

hIcon := DllCall("user32\LoadIcon", Ptr,0, Ptr,32512, Ptr) ;IDI_APPLICATION := 32512
hIconDT := LoadPicture("shell32.dll", "w16 h16 icon35", vType)
hIconDTBig := LoadPicture("shell32.dll", "w32 h32 icon35", vType)

Gui, 2:New, +HwndhGui2 -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, 2:Color, 242424
Gui, 2:Font, s11, Consolas
Gui, 2:Add, ListView, x-2 y20 w480 h60 +LV0x3 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +Background242424

Gui, New, +HwndhGui -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, Font, s11, Consolas
Gui, Color, 242424
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y80 w415 h28 vMyLabel cWhite Background242424, Embossed Window
Gui, Add, ListView, x-2 y20 w480 h57 +LV0x3 +LV0x8000 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +Background242424
return
  
;==================================================

GuiClose:
Gui, 2:Hide
ExitApp
return

;==================================================

^!Tab::
vKeepOpen := true
vIndex++
if (vIndex > oHWnd.MaxIndex())
    vIndex := 1
LV_Modify(0, "-Select")
LV_Modify(vIndex, "Select Vis")
goto HandleAltTab

!Tab::
+!Tab::
vKeepOpen := false
vIndex += InStr(A_ThisHotkey, "+") ? -1 : 1

HandleAltTab:
Gui, % hGui2 ":Default"
Gui, % hGui ":Default"

if !DllCall("user32\IsWindowVisible", "Ptr",hGui2)
if !DllCall("user32\IsWindowVisible", "Ptr",hGui)
{
    Hotkey, IfWinActive, % "ahk_id " hGui2
    Hotkey, IfWinActive, % "ahk_id " hGui
    Hotkey, *Esc, DoCancel, On
    LV_Delete(), IL_Destroy(hIL)
    hIL := IL_Create(28, 28, 1)
    LV_SetImageList(hIL)
    vCount := 0, vPrompt := "", oHWnd := {}, oTitle := {}, oHIcon := {}, oHIconBig := {}
    Loop % vListCount
    {
        if (A_Index = vListVisibleWindows)
        {
            DetectHiddenWindows, Off
            WinGet, vWinList, List
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd[vCount] := hWnd
                oTitle[vCount] := vFileName
                oHIcon[vCount] := JEE_WinGetIcon(hWnd, 1)
                oHIconBig[vCount] := JEE_WinGetIcon(hWnd, 1)
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)  
                LV_ModifyCol(1, 40)
            }

            DetectHiddenWindows, On
        }

        vDesktopFound := false

        Loop, % oHWnd.MaxIndex()
        {
            if (oTitle[A_Index] = "Desktop")
            {
                vDesktopFound := true
                break
            }
        }

        if !vDesktopFound
        {
            vCount += 1
            oHWnd[vCount] := "Desktop"
            oTitle[vCount] := "Desktop"
            oHIcon[vCount] := hIconDT
            oHIconBig[vCount] := hIconDTBig
            IL_Add(hIL, "HICON:*" oHIcon[vCount])
            LV_Add("Icon" vCount)
        }

        if (A_Index = vListIntExpTabs)
        {
            WinGet, vWinList, List, ahk_class TabThumbnailWindow
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd.Push(hWnd)
                oTitle.Push(vFileName)
                oHIcon.Push(JEE_WinGetIcon(hWnd, 1))
                oHIconBig.Push(JEE_WinGetIcon(hWnd, 1))
                ToolTip, % "Title: " oTitle[vCount] " | Icon Index: " vCount
                Sleep, 500
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)  
                LV_ModifyCol(1, 40)
            }

        }
    }

    ;Loop 2
    ;    LV_Add("Icon0", "")
    ;==============================
    vIndex := 2
    WinSetRegion(hGui2, 20)
    WinSetRegion(hGui, 20)
    SetTimer, CheckAlt, 5
    SetTimer, HandleAltTab, 10

;---------GET CENTER OF CURRENT MONITOR---------
        ;get current monitor index
        CurrentMonitorIndex:=GetCurrentMonitorIndex()
        ;get Hwnd of current GUI
        DetectHiddenWindows On
        Gui, 2:Show, w457 H117
        Gui, +LastFound
        WinSet, TransColor, F0F0F0
        Gui, Show, w457 h122
        GUI_Hwnd := WinExist()
        ;Calculate size of GUI
        GetClientSize(GUI_Hwnd,GUI_Width,GUI_Height)
        DetectHiddenWindows Off
        ;Calculate where the GUI should be positioned
        GUI_X:=CoordXCenterScreen(GUI_Width,CurrentMonitorIndex)
        GUI_Y:=CoordYCenterScreen(GUI_Height,CurrentMonitorIndex)

        ;------- / GET CENTER OF CURRENT MONITOR---------
        ;SHOW GUI AT CENTER OF CURRENT SCREEN
        Gui, 2:Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Gui, Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Return

        GetCurrentMonitorIndex(){
        CoordMode, Mouse, Screen
        MouseGetPos, mx, my
        SysGet, monitorsCount, 80

        Loop %monitorsCount%{
            SysGet, monitor, Monitor, %A_Index%
            if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
                Return A_Index
                }
            }
            Return 1
    }

        CoordXCenterScreen(WidthOfGUI,ScreenNumber)
    {
        SysGet, Mon1, Monitor, %ScreenNumber%
        return (( Mon1Right-Mon1Left - WidthOfGUI ) / 2) + Mon1Left
    }

    CoordYCenterScreen(HeightofGUI,ScreenNumber){
        SysGet, Mon1, Monitor, %ScreenNumber%
        return ((Mon1Bottom-Mon1Top - 30 - HeightofGUI ) / 2) + Mon1Top
    }

    GetClientSize(hwnd, ByRef w, ByRef h)
    {
        VarSetCapacity(rc, 16)
        DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
        w := NumGet(rc, 8, "int")
        h := NumGet(rc, 12, "int")
    }  
}

if (vIndex < 1)
    vIndex := vCount
if (vIndex > vCount)
    vIndex := 1

ControlSetText,, % oTitle[vIndex], % "ahk_id " hStc
SendMessage, 0x170, % oHIcon[vIndex], 0,, % "ahk_id " hStcImg ;STM_SETICON := 0x170

LV_Modify(0, "-Select")
LV_Modify(vIndex, "Vis")
LV_Modify(vIndex, "Select Vis")
return

;==================================================

CheckAlt:
if !GetKeyState("Alt", "P") && !vKeepOpen
{
    SetTimer, CheckAlt, Off
    SetTimer, HandleAltTab, Off
    if WinExist("ahk_id " hGui) {
        WinHide, ahk_id %hGui%
        if WinExist("ahk_id " hGui2)
            WinHide, ahk_id %hGui2%
    }
    DetectHiddenWindows, On
    if (oTitle[vIndex] = "Desktop")
    {
        DllCall("user32\ShowWindow", "Ptr", hGui2, "Int", 0)
        DllCall("user32\ShowWindow", "Ptr", hGui, "Int", 0)
        WinMinimizeAll
    }
    else
    {
        WinActivate, % "ahk_id " oHWnd[vIndex]
    }
}
return

;==================================================

#If WinActive("ahk_id " hGui2)
#If WinActive("ahk_id " hGui)

Tab::
Right::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

+Tab::
Left::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelUp::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelDown::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

Enter::
NumpadEnter::
Space::
    if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
        WinActivate, % "ahk_id " oHWnd[vIndex]
        vKeepOpen := false
        SetTimer, HandleAltTab, Off
        Gui, 2:Hide
        Gui, Hide
    }
return

Esc::
    vKeepOpen := false
    SetTimer, HandleAltTab, Off
    LV_Modify(0, "-Select")
    vIndex := 0
    Gui, 2:Hide
    Gui, Hide
return
#If

;==================================================

OnListViewClick:
    if (A_GuiEvent = "Normal") {
        LV_GetText(vSelectedTitle, A_EventInfo, 1)
        vIndex := A_EventInfo
        if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
            WinActivate, % "ahk_id " oHWnd[vIndex]
            vKeepOpen := false
            SetTimer, HandleAltTab, Off
            Gui, 2:Hide
            Gui, Hide
        }
    }
return

;==================================================

DoCancel:
SetTimer, CheckAlt, Off
Hotkey, IfWinActive, % "ahk_id " hGui2
Hotkey, IfWinActive, % "ahk_id " hGui
Hotkey, *Esc, DoCancel, Off
WinHide, % "ahk_id " hGui2
WinHide, % "ahk_id " hGui
return

;==================================================

JEE_WinGetIcon(hWnd, vDoGetBig:=0)
{
    static vSfx := (A_PtrSize=8) ? "Ptr" : ""
    if !hWnd || !WinExist("ahk_id " hWnd)
        return 0
    if vDoGetBig
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    else
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    return 0
}

;==================================================

JEE_WinHasTaskbarButton(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
    || DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    if DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
        return 0
    return 1
}

;==================================================

JEE_WinHasAltTabIcon(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
    || (vWinStyle & 0x8000000) ;WS_DISABLED := 0x8000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
    || (vWinExStyle & 0x8000000) ;WS_EX_NOACTIVATE := 0x8000000
        return 0
    return 1
}

;==================================================

WinSetRegion(hWnd, Radius := 20)
{
    hRgn := DllCall("gdi32\CreateRoundRectRgn", "Int", 0, "Int", 0, "Int", 457, "Int", 122, "Int", Radius, "Int", Radius, "Ptr")
    DllCall("user32\SetWindowRgn", "Ptr", hWnd, "Ptr", hRgn, "Int", 1)
}


1746729860343.webp

Code:
;Alt-Tab Reincarnation

#SingleInstance force
ListLines, Off
#KeyHistory 0
Menu, Tray, Click, 1
;Menu, Tray, NoIcon
#NoEnv
AutoTrim, Off
#UseHook
#MaxThreadsPerHotKey 2

SetKeyDelay, 0, 20

SplitPath, A_ScriptName,,,, vScriptNameNoExt
Menu, Tray, Tip, % vScriptNameNoExt

;==================================================

vListVisibleWindows := 1
vListCount := 4

;==================================================

hIcon := DllCall("user32\LoadIcon", Ptr,0, Ptr,32512, Ptr) ;IDI_APPLICATION := 32512
hIconDT := LoadPicture("shell32.dll", "w16 h16 icon35", vType)
hIconDTBig := LoadPicture("shell32.dll", "w32 h32 icon35", vType)

Gui, 2:New, +HwndhGui2 -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, 2:Color, 242424
Gui, 2:Font, s11, Consolas
Gui, 2:Add, ListView, x-2 y20 w480 h210 +LV0x3 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +Background242424

Gui, New, +HwndhGui -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, Font, s11, Consolas
Gui, Color, 242424
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y230 w415 h28 vMyLabel cWhite Background242424, Embossed Window
Gui, Add, ListView, x-2 y20 w480 h210 +LV0x3 +LV0x8000 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +Background242424
return
  
;==================================================

GuiClose:
Gui, 2:Hide
ExitApp
return

;==================================================

^!Tab::
vKeepOpen := true
vIndex++
if (vIndex > oHWnd.MaxIndex())
    vIndex := 1
LV_Modify(0, "-Select")
LV_Modify(vIndex, "Select Vis")
goto HandleAltTab

!Tab::
+!Tab::
vKeepOpen := false
vIndex += InStr(A_ThisHotkey, "+") ? -1 : 1

HandleAltTab:
Gui, % hGui2 ":Default"
Gui, % hGui ":Default"

if !DllCall("user32\IsWindowVisible", "Ptr",hGui2)
if !DllCall("user32\IsWindowVisible", "Ptr",hGui)
{
    Hotkey, IfWinActive, % "ahk_id " hGui2
    Hotkey, IfWinActive, % "ahk_id " hGui
    Hotkey, *Esc, DoCancel, On
    LV_Delete(), IL_Destroy(hIL)
    hIL := IL_Create(28, 28, 1)
    LV_SetImageList(hIL)
    vCount := 0, vPrompt := "", oHWnd := {}, oTitle := {}, oHIcon := {}, oHIconBig := {}
    Loop % vListCount
    {
        if (A_Index = vListVisibleWindows)
        {
            DetectHiddenWindows, Off
            WinGet, vWinList, List
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd[vCount] := hWnd
                oTitle[vCount] := vFileName
                oHIcon[vCount] := JEE_WinGetIcon(hWnd, 1)
                oHIconBig[vCount] := JEE_WinGetIcon(hWnd, 1)
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)  
                LV_ModifyCol(1, 40)
            }

            DetectHiddenWindows, On
        }

        vDesktopFound := false

        Loop, % oHWnd.MaxIndex()
        {
            if (oTitle[A_Index] = "Desktop")
            {
                vDesktopFound := true
                break
            }
        }

        if !vDesktopFound
        {
            vCount += 1
            oHWnd[vCount] := "Desktop"
            oTitle[vCount] := "Desktop"
            oHIcon[vCount] := hIconDT
            oHIconBig[vCount] := hIconDTBig
            IL_Add(hIL, "HICON:*" oHIcon[vCount])
            LV_Add("Icon" vCount)
        }

        if (A_Index = vListIntExpTabs)
        {
            WinGet, vWinList, List, ahk_class TabThumbnailWindow
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd.Push(hWnd)
                oTitle.Push(vFileName)
                oHIcon.Push(JEE_WinGetIcon(hWnd, 1))
                oHIconBig.Push(JEE_WinGetIcon(hWnd, 1))
                ToolTip, % "Title: " oTitle[vCount] " | Icon Index: " vCount
                Sleep, 500
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)  
                LV_ModifyCol(1, 40)
            }

        }
    }

    ;Loop 2
    ;    LV_Add("Icon0", "")
    ;==============================
    vIndex := 2
    SetTimer, CheckAlt, 5
    SetTimer, HandleAltTab, 10

;---------GET CENTER OF CURRENT MONITOR---------
        ;get current monitor index
        CurrentMonitorIndex:=GetCurrentMonitorIndex()
        ;get Hwnd of current GUI
        DetectHiddenWindows On
        Gui, 2:Show, w457 H266
        Gui, +LastFound
        WinSet, TransColor, F0F0F0
        Gui, Show, w457 h271
        GUI_Hwnd := WinExist()
        ;Calculate size of GUI
        GetClientSize(GUI_Hwnd,GUI_Width,GUI_Height)
        DetectHiddenWindows Off
        ;Calculate where the GUI should be positioned
        GUI_X:=CoordXCenterScreen(GUI_Width,CurrentMonitorIndex)
        GUI_Y:=CoordYCenterScreen(GUI_Height,CurrentMonitorIndex)

        ;------- / GET CENTER OF CURRENT MONITOR---------
        ;SHOW GUI AT CENTER OF CURRENT SCREEN
        Gui, 2:Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Gui, Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Return

        GetCurrentMonitorIndex(){
        CoordMode, Mouse, Screen
        MouseGetPos, mx, my
        SysGet, monitorsCount, 80

        Loop %monitorsCount%{
            SysGet, monitor, Monitor, %A_Index%
            if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
                Return A_Index
                }
            }
            Return 1
    }

        CoordXCenterScreen(WidthOfGUI,ScreenNumber)
    {
        SysGet, Mon1, Monitor, %ScreenNumber%
        return (( Mon1Right-Mon1Left - WidthOfGUI ) / 2) + Mon1Left
    }

    CoordYCenterScreen(HeightofGUI,ScreenNumber){
        SysGet, Mon1, Monitor, %ScreenNumber%
        return ((Mon1Bottom-Mon1Top - 30 - HeightofGUI ) / 2) + Mon1Top
    }

    GetClientSize(hwnd, ByRef w, ByRef h)
    {
        VarSetCapacity(rc, 16)
        DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
        w := NumGet(rc, 8, "int")
        h := NumGet(rc, 12, "int")
    }
}

if (vIndex < 1)
    vIndex := vCount
if (vIndex > vCount)
    vIndex := 1

ControlSetText,, % oTitle[vIndex], % "ahk_id " hStc
SendMessage, 0x170, % oHIcon[vIndex], 0,, % "ahk_id " hStcImg ;STM_SETICON := 0x170

LV_Modify(0, "-Select")
LV_Modify(vIndex, "Vis")
LV_Modify(vIndex, "Select Vis")
return

;==================================================

CheckAlt:
if !GetKeyState("Alt", "P") && !vKeepOpen
{
    SetTimer, CheckAlt, Off
    SetTimer, HandleAltTab, Off
    if WinExist("ahk_id " hGui) {
        WinHide, ahk_id %hGui%
        if WinExist("ahk_id " hGui2)
            WinHide, ahk_id %hGui2%
    }
    DetectHiddenWindows, On
    if (oTitle[vIndex] = "Desktop")
    {
        DllCall("user32\ShowWindow", "Ptr", hGui2, "Int", 0)
        DllCall("user32\ShowWindow", "Ptr", hGui, "Int", 0)
        WinMinimizeAll
    }
    else
    {
        WinActivate, % "ahk_id " oHWnd[vIndex]
    }
}
return

;==================================================

#If WinActive("ahk_id " hGui2)
#If WinActive("ahk_id " hGui)

Tab::
Right::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

+Tab::
Left::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()

    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelUp::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelDown::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

Enter::
NumpadEnter::
Space::
    if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
        WinActivate, % "ahk_id " oHWnd[vIndex]
        vKeepOpen := false
        SetTimer, HandleAltTab, Off
        Gui, Hide
    }
return

Esc::
    vKeepOpen := false
    SetTimer, HandleAltTab, Off
    LV_Modify(0, "-Select")
    vIndex := 0
    Gui, 2:Hide
    Gui, Hide
return
#If

;==================================================

OnListViewClick:
    if (A_GuiEvent = "Normal") {
        LV_GetText(vSelectedTitle, A_EventInfo, 1)
        vIndex := A_EventInfo
        if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
            WinActivate, % "ahk_id " oHWnd[vIndex]
            vKeepOpen := false
            SetTimer, HandleAltTab, Off
            Gui, 2:Hide
            Gui, Hide
        }
    }
return

;==================================================

DoCancel:
SetTimer, CheckAlt, Off
Hotkey, IfWinActive, % "ahk_id " hGui2
Hotkey, IfWinActive, % "ahk_id " hGui
Hotkey, *Esc, DoCancel, Off
WinHide, % "ahk_id " hGui2
WinHide, % "ahk_id " hGui
return

;==================================================

JEE_WinGetIcon(hWnd, vDoGetBig:=0)
{
    static vSfx := (A_PtrSize=8) ? "Ptr" : ""
    if !hWnd || !WinExist("ahk_id " hWnd)
        return 0
    if vDoGetBig
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    else
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    return 0
}

;==================================================

JEE_WinHasTaskbarButton(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
    || DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    if DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
        return 0
    return 1
}

;==================================================

JEE_WinHasAltTabIcon(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
    || (vWinStyle & 0x8000000) ;WS_DISABLED := 0x8000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
    || (vWinExStyle & 0x8000000) ;WS_EX_NOACTIVATE := 0x8000000
        return 0
    return 1
}

;==================================================

WinSetRegion(hWnd, Radius := 20)
{
    hRgn := DllCall("gdi32\CreateRoundRectRgn", "Int", 0, "Int", 0, "Int", 457, "Int", 271, "Int", Radius, "Int", Radius, "Ptr")
    DllCall("user32\SetWindowRgn", "Ptr", hWnd, "Ptr", hRgn, "Int", 1)
}


1746730132612.webp

Code:
;Alt-Tab Reincarnation

#SingleInstance force
ListLines, Off
#KeyHistory 0
Menu, Tray, Click, 1
;Menu, Tray, NoIcon
#NoEnv
AutoTrim, Off
#UseHook
#MaxThreadsPerHotKey 2

SetKeyDelay, 0, 20

SplitPath, A_ScriptName,,,, vScriptNameNoExt
Menu, Tray, Tip, % vScriptNameNoExt

;==================================================

vListVisibleWindows := 1
vListCount := 4

;==================================================

hIcon := DllCall("user32\LoadIcon", Ptr,0, Ptr,32512, Ptr) ;IDI_APPLICATION := 32512
hIconDT := LoadPicture("shell32.dll", "w16 h16 icon35", vType)
hIconDTBig := LoadPicture("shell32.dll", "w32 h32 icon35", vType)

Gui, 2:New, +HwndhGui2 -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, 2:Color, 242424
Gui, 2:Font, s11, Consolas
Gui, 2:Add, ListView, x-2 y20 w480 h210 +LV0x3 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +Background242424

Gui, New, +HwndhGui -Caption +AlwaysOnTop, <a>Alt-Tab Reincarnation</a>, Embossed Window
Gui, Font, s11, Consolas
Gui, Color, 242424
Gui, Add, Text, +HwndhStc +E0x200 +Border x20 y230 w415 h28 vMyLabel cWhite Background242424, Embossed Window
Gui, Add, ListView, x-2 y20 w480 h210 +LV0x3 +LV0x8000 +LV0x10000 +AltSubmit +Icon +gOnListViewClick +Grid -E0x200 +Background242424
return
  
;==================================================

GuiClose:
Gui, 2:Hide
ExitApp
return

;==================================================

^!Tab::
vKeepOpen := true
vIndex++
if (vIndex > oHWnd.MaxIndex())
    vIndex := 1
LV_Modify(0, "-Select")
LV_Modify(vIndex, "Select Vis")
goto HandleAltTab

!Tab::
+!Tab::
vKeepOpen := false
vIndex += InStr(A_ThisHotkey, "+") ? -1 : 1

HandleAltTab:
Gui, % hGui2 ":Default"
Gui, % hGui ":Default"

if !DllCall("user32\IsWindowVisible", "Ptr",hGui2)
if !DllCall("user32\IsWindowVisible", "Ptr",hGui)
{
    Hotkey, IfWinActive, % "ahk_id " hGui2
    Hotkey, IfWinActive, % "ahk_id " hGui
    Hotkey, *Esc, DoCancel, On
    LV_Delete(), IL_Destroy(hIL)
    hIL := IL_Create(28, 28, 1)
    LV_SetImageList(hIL)
    vCount := 0, vPrompt := "", oHWnd := {}, oTitle := {}, oHIcon := {}, oHIconBig := {}
    Loop % vListCount
    {
        if (A_Index = vListVisibleWindows)
        {
            DetectHiddenWindows, Off
            WinGet, vWinList, List
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd[vCount] := hWnd
                oTitle[vCount] := vFileName
                oHIcon[vCount] := JEE_WinGetIcon(hWnd, 1)
                oHIconBig[vCount] := JEE_WinGetIcon(hWnd, 1)
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)  
                LV_ModifyCol(1, 40)
            }

            DetectHiddenWindows, On
        }

        vDesktopFound := false

        Loop, % oHWnd.MaxIndex()
        {
            if (oTitle[A_Index] = "Desktop")
            {
                vDesktopFound := true
                break
            }
        }

        if !vDesktopFound
        {
            vCount += 1
            oHWnd[vCount] := "Desktop"
            oTitle[vCount] := "Desktop"
            oHIcon[vCount] := hIconDT
            oHIconBig[vCount] := hIconDTBig
            IL_Add(hIL, "HICON:*" oHIcon[vCount])
            LV_Add("Icon" vCount)
        }

        if (A_Index = vListIntExpTabs)
        {
            WinGet, vWinList, List, ahk_class TabThumbnailWindow
            Loop % vWinList
            {
                hWnd := vWinList%A_Index%
                if !JEE_WinHasAltTabIcon(hWnd)
                    continue
                WinGetTitle, vWinTitle, % "ahk_id " hWnd
                SplitPath, vWinTitle, vFileName
                vCount += 1
                oHWnd.Push(hWnd)
                oTitle.Push(vFileName)
                oHIcon.Push(JEE_WinGetIcon(hWnd, 1))
                oHIconBig.Push(JEE_WinGetIcon(hWnd, 1))
                ToolTip, % "Title: " oTitle[vCount] " | Icon Index: " vCount
                Sleep, 500
                IL_Add(hIL, "HICON:" oHIcon[vCount])
                LV_Add("Icon" vCount)  
                LV_ModifyCol(1, 40)
            }

        }
    }

    ;Loop 2
    ;    LV_Add("Icon0", "")
    ;==============================
    vIndex := 2
    WinSetRegion(hGui2, 20)
    WinSetRegion(hGui, 20)
    SetTimer, CheckAlt, 5
    SetTimer, HandleAltTab, 10

;---------GET CENTER OF CURRENT MONITOR---------
        ;get current monitor index
        CurrentMonitorIndex:=GetCurrentMonitorIndex()
        ;get Hwnd of current GUI
        DetectHiddenWindows On
        Gui, 2:Show, w457 H266
        Gui, +LastFound
        WinSet, TransColor, F0F0F0
        Gui, Show, w457 h271
        GUI_Hwnd := WinExist()
        ;Calculate size of GUI
        GetClientSize(GUI_Hwnd,GUI_Width,GUI_Height)
        DetectHiddenWindows Off
        ;Calculate where the GUI should be positioned
        GUI_X:=CoordXCenterScreen(GUI_Width,CurrentMonitorIndex)
        GUI_Y:=CoordYCenterScreen(GUI_Height,CurrentMonitorIndex)

        ;------- / GET CENTER OF CURRENT MONITOR---------
        ;SHOW GUI AT CENTER OF CURRENT SCREEN
        Gui, 2:Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Gui, Show, % "x" GUI_X " y" GUI_Y, ;title of window
        Return

        GetCurrentMonitorIndex(){
        CoordMode, Mouse, Screen
        MouseGetPos, mx, my
        SysGet, monitorsCount, 80

        Loop %monitorsCount%{
            SysGet, monitor, Monitor, %A_Index%
            if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
                Return A_Index
                }
            }
            Return 1
    }

        CoordXCenterScreen(WidthOfGUI,ScreenNumber)
    {
        SysGet, Mon1, Monitor, %ScreenNumber%
        return (( Mon1Right-Mon1Left - WidthOfGUI ) / 2) + Mon1Left
    }

    CoordYCenterScreen(HeightofGUI,ScreenNumber){
        SysGet, Mon1, Monitor, %ScreenNumber%
        return ((Mon1Bottom-Mon1Top - 30 - HeightofGUI ) / 2) + Mon1Top
    }

    GetClientSize(hwnd, ByRef w, ByRef h)
    {
        VarSetCapacity(rc, 16)
        DllCall("GetClientRect", "uint", hwnd, "uint", &rc)
        w := NumGet(rc, 8, "int")
        h := NumGet(rc, 12, "int")
    }
}

if (vIndex < 1)
    vIndex := vCount
if (vIndex > vCount)
    vIndex := 1

ControlSetText,, % oTitle[vIndex], % "ahk_id " hStc
SendMessage, 0x170, % oHIcon[vIndex], 0,, % "ahk_id " hStcImg ;STM_SETICON := 0x170

LV_Modify(0, "-Select")
LV_Modify(vIndex, "Vis")
LV_Modify(vIndex, "Select Vis")
return

;==================================================

CheckAlt:
if !GetKeyState("Alt", "P") && !vKeepOpen
{
    SetTimer, CheckAlt, Off
    SetTimer, HandleAltTab, Off
    if WinExist("ahk_id " hGui) {
        WinHide, ahk_id %hGui%
        if WinExist("ahk_id " hGui2)
            WinHide, ahk_id %hGui2%
    }
    DetectHiddenWindows, On
    if (oTitle[vIndex] = "Desktop")
    {
        DllCall("user32\ShowWindow", "Ptr", hGui2, "Int", 0)
        DllCall("user32\ShowWindow", "Ptr", hGui, "Int", 0)
        WinMinimizeAll
    }
    else
    {
        WinActivate, % "ahk_id " oHWnd[vIndex]
    }
}
return

;==================================================

#If WinActive("ahk_id " hGui2)
#If WinActive("ahk_id " hGui)

Tab::
Right::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

+Tab::
Left::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()

    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelUp::
    if (vIndex > 1)
        vIndex--
    else
        vIndex := oHWnd.MaxIndex()
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

WheelDown::
    if (vIndex < vCount)
        vIndex++
    else
        vIndex := 1
    LV_Modify(0, "-Select")
    LV_Modify(vIndex, "Select Vis")
return

Enter::
NumpadEnter::
Space::
    if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
        WinActivate, % "ahk_id " oHWnd[vIndex]
        vKeepOpen := false
        SetTimer, HandleAltTab, Off
        Gui, Hide
    }
return

Esc::
    vKeepOpen := false
    SetTimer, HandleAltTab, Off
    LV_Modify(0, "-Select")
    vIndex := 0
    Gui, 2:Hide
    Gui, Hide
return
#If

;==================================================

OnListViewClick:
    if (A_GuiEvent = "Normal") {
        LV_GetText(vSelectedTitle, A_EventInfo, 1)
        vIndex := A_EventInfo
        if (vIndex > 0 && vIndex <= oHWnd.MaxIndex()) {
            WinActivate, % "ahk_id " oHWnd[vIndex]
            vKeepOpen := false
            SetTimer, HandleAltTab, Off
            Gui, 2:Hide
            Gui, Hide
        }
    }
return

;==================================================

DoCancel:
SetTimer, CheckAlt, Off
Hotkey, IfWinActive, % "ahk_id " hGui2
Hotkey, IfWinActive, % "ahk_id " hGui
Hotkey, *Esc, DoCancel, Off
WinHide, % "ahk_id " hGui2
WinHide, % "ahk_id " hGui
return

;==================================================

JEE_WinGetIcon(hWnd, vDoGetBig:=0)
{
    static vSfx := (A_PtrSize=8) ? "Ptr" : ""
    if !hWnd || !WinExist("ahk_id " hWnd)
        return 0
    if vDoGetBig
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    else
    {
        if (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",0, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL := 0
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",2, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_SMALL2 := 2
        || (hIcon := DllCall("user32\SendMessage", "Ptr",hWnd, "UInt",0x7F, "UPtr",1, "Ptr",0, "Ptr")) ;WM_GETICON := 0x7F ;ICON_BIG := 1
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-34, "UPtr")) ;GCL_HICONSM := -34
        || (hIcon := DllCall("user32\GetClassLong" vSfx, "Ptr",hWnd, "Int",-14, "UPtr")) ;GCL_HICON := -14
        || (hIcon := DllCall("user32\LoadIcon", "Ptr",0, "Ptr",32512, "Ptr")) ;IDI_APPLICATION := 32512
            return hIcon
    }
    return 0
}

;==================================================

JEE_WinHasTaskbarButton(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
    || DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    if DllCall("user32\GetWindow", "Ptr",hWnd, "UInt",4, "Ptr") ;GW_OWNER := 4 ;affects taskbar but not alt-tab
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
        return 0
    return 1
}

;==================================================

JEE_WinHasAltTabIcon(hWnd)
{
    local
    if !(DllCall("user32\GetDesktopWindow", "Ptr") = DllCall("user32\GetAncestor", "Ptr",hWnd, "UInt",1, "Ptr")) ;GA_PARENT := 1
        return 0
    WinGet, vWinStyle, Style, % "ahk_id " hWnd
    if !vWinStyle
    || !(vWinStyle & 0x10000000) ;WS_VISIBLE := 0x10000000
    || (vWinStyle & 0x8000000) ;WS_DISABLED := 0x8000000
        return 0
    WinGet, vWinExStyle, ExStyle, % "ahk_id " hWnd
    if (vWinExStyle & 0x40000) ;WS_EX_APPWINDOW := 0x40000
        return 1
    if (vWinExStyle & 0x80) ;WS_EX_TOOLWINDOW := 0x80
    || (vWinExStyle & 0x8000000) ;WS_EX_NOACTIVATE := 0x8000000
        return 0
    return 1
}

;==================================================

WinSetRegion(hWnd, Radius := 20)
{
    hRgn := DllCall("gdi32\CreateRoundRectRgn", "Int", 0, "Int", 0, "Int", 457, "Int", 271, "Int", Radius, "Int", Radius, "Ptr")
    DllCall("user32\SetWindowRgn", "Ptr", hWnd, "Ptr", hRgn, "Int", 1)
}
 

Attachments

Last edited:

My Computer

System One

  • OS
    Windows 11 Pro
once its fully working as an alt+tab hotkey replacement, i will post the final code, share the .pyw file (python .py file (w makes it so the console does not show)) and also compile it to a .exe and share that for people that do not want to have to compile it themselves. will hopefully be finished this week.
I am eagerly looking forward to the exe version. Thank you in advance for your efforts.
 

My Computer

System One

  • OS
    Windows 11 Home
    Computer type
    Laptop
Updated. See original post.
 

My Computer

System One

  • OS
    Windows 11 Pro
Sumpthin is not right...,
hang on......
I'm getting ghost frames..., and the text isn't showing on the bottom of the UI...

9292.webp

9293.webp

9294.webp
 

My Computers

System One System Two

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    ASUS ROG Strix
  • Operating System
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    ASUS VivoBook
Odd. Looks like you’re using rounded 3 row, right? Do the others have that effect on your pc? I tested on a laptop with 1080p res and a desktop with 4k res. Scaling should be good
 

My Computer

System One

  • OS
    Windows 11 Pro
Odd. Looks like you’re using rounded 3 row, right? Do the others have that effect on your pc? I tested on a laptop with 1080p res and a desktop with 4k res. Scaling should be good
Could be sumpthin funky on my end...,
lemme check a few things out......
 

My Computers

System One System Two

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    ASUS ROG Strix
  • Operating System
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    ASUS VivoBook
Sounds good. I’d be interested in knowing if anyone else has that issue too.
 

My Computer

System One

  • OS
    Windows 11 Pro
Sounds good. I’d be interested in knowing if anyone else has that issue too.
On my Canary vanilla Laptop, the text box is inside but, the 2 larger ghost frames are still there.

9516.webp
 

My Computers

System One System Two

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    ASUS ROG Strix
  • Operating System
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    ASUS VivoBook

My Computers

System One System Two

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    ASUS ROG Strix
  • Operating System
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    ASUS VivoBook
That gif was on Canary vanilla, no SAB, no QTTabBar, at 1920x1080.

Nope.
make sure to kill it in the task manager. try running this test for me. should be rounded with 3 rows.
 

My Computer

System One

  • OS
    Windows 11 Pro
make sure to kill it in the task manager. try running this test for me. should be rounded with 3 rows.
Same as in Post #10
 

My Computers

System One System Two

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    ASUS ROG Strix
  • Operating System
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    ASUS VivoBook
Back
Top Bottom