- Local time
- 5:23 AM
- Posts
- 3,393
- OS
- Windows 11 Pro
UPDATE 08 MAY 2025:
Python was giving me
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:
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

Original Classic Alt+Tab for Comparison:

_______________________________________________________________________________________________________________________________________________




_______________________________________________________________________________________________________________________________________________
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

_______________________________________________________________________________________________________________________________________________
Python was giving me

*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 Downward | Cycle Clockwise |
Shift+Tab / Left Arrow / Mouse Wheel Scroll Upward | Cycle Counter-Clockwise |
Spacebar / Enter / Single Click Mouse Left Button | Launch Selected Program / Window |
Esc | Hide 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

Original Classic Alt+Tab for Comparison:

_______________________________________________________________________________________________________________________________________________

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)
}

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)
}

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)
}

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

_______________________________________________________________________________________________________________________________________________
Attachments
Last edited:
My Computer
System One
-
- OS
- Windows 11 Pro