Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WS_EX_APPWINDOW = 0x40000 ; provides a taskbar button
- WS_EX_TOOLWINDOW = 0x80 ; removes the window from the alt-tab list
- GW_OWNER = 4
- AltTabWindows()
- Gui, Add, ListView, r20 w700, #|ID|Title
- Loop, %AltTabTotalNum%
- {
- WinGetTitle, title, % "ahk_id " windowList%A_Index%
- LV_Add("", A_Index, windowList%A_Index%, title)
- }
- LV_ModifyCol() ; Auto-size each column to fit its contents.
- Gui, Show
- return
- GuiClose:
- Exitapp
- AltTabWindows() {
- Global
- AltTabTotalNum := 0 ; the number of windows found
- AltTabListID_1 = ; hwnd from last active windows
- AltTabListID_2 = ; hwnd from previous active windows
- windowList_ = 0
- DetectHiddenWindows, Off ; makes DllCall("IsWindowVisible") unnecessary
- WinGet, windowList, List ; gather a list of running programs
- Loop, %windowList%
- {
- ownerID := windowID := windowList%A_Index%
- Loop {
- ownerID := Decimal_to_Hex( DllCall("GetWindow", "UInt", ownerID, "UInt", GW_OWNER))
- } Until !Decimal_to_Hex( DllCall("GetWindow", "UInt", ownerID, "UInt", GW_OWNER))
- ownerID := ownerID ? ownerID : windowID
- If (Decimal_to_Hex(DllCall("GetLastActivePopup", "UInt", ownerID)) = windowID)
- {
- WinGet, es, ExStyle, ahk_id %windowID%
- If (!((es & WS_EX_TOOLWINDOW) && !(es & WS_EX_APPWINDOW)) && !IsInvisibleWin10BackgroundAppWindow(windowID))
- {
- AltTabTotalNum ++
- AltTabListID_%AltTabTotalNum% := windowID
- }
- }
- }
- }
- IsInvisibleWin10BackgroundAppWindow(hWindow) {
- result := 0
- VarSetCapacity(cloakedVal, A_PtrSize) ; DWMWA_CLOAKED := 14
- hr := DllCall("DwmApi\DwmGetWindowAttribute", "Ptr", hWindow, "UInt", 14, "Ptr", &cloakedVal, "UInt", A_PtrSize)
- if !hr ; returns S_OK (which is zero) on success. Otherwise, it returns an HRESULT error code
- result := NumGet(cloakedVal) ; omitting the "&" performs better
- return result ? true : false
- }
- Decimal_to_Hex(var)
- {
- SetFormat, integer, hex
- var += 0
- SetFormat, integer, d
- return var
- }
Add Comment
Please, Sign In to add comment