Guest User

Untitled

a guest
Mar 24th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1.  
  2. WS_EX_APPWINDOW = 0x40000 ; provides a taskbar button
  3. WS_EX_TOOLWINDOW = 0x80 ; removes the window from the alt-tab list
  4. GW_OWNER = 4
  5.  
  6. AltTabWindows()
  7.  
  8. Gui, Add, ListView, r20 w700, #|ID|Title
  9. Loop, %AltTabTotalNum%
  10. {
  11. WinGetTitle, title, % "ahk_id " windowList%A_Index%
  12. LV_Add("", A_Index, windowList%A_Index%, title)
  13. }
  14. LV_ModifyCol() ; Auto-size each column to fit its contents.
  15. Gui, Show
  16. return
  17.  
  18. GuiClose:
  19. Exitapp
  20.  
  21. AltTabWindows() {
  22. Global
  23. AltTabTotalNum := 0 ; the number of windows found
  24. AltTabListID_1 = ; hwnd from last active windows
  25. AltTabListID_2 = ; hwnd from previous active windows
  26. windowList_ = 0
  27. DetectHiddenWindows, Off ; makes DllCall("IsWindowVisible") unnecessary
  28. WinGet, windowList, List ; gather a list of running programs
  29. Loop, %windowList%
  30. {
  31. ownerID := windowID := windowList%A_Index%
  32. Loop {
  33. ownerID := Decimal_to_Hex( DllCall("GetWindow", "UInt", ownerID, "UInt", GW_OWNER))
  34. } Until !Decimal_to_Hex( DllCall("GetWindow", "UInt", ownerID, "UInt", GW_OWNER))
  35. ownerID := ownerID ? ownerID : windowID
  36. If (Decimal_to_Hex(DllCall("GetLastActivePopup", "UInt", ownerID)) = windowID)
  37. {
  38. WinGet, es, ExStyle, ahk_id %windowID%
  39. If (!((es & WS_EX_TOOLWINDOW) && !(es & WS_EX_APPWINDOW)) && !IsInvisibleWin10BackgroundAppWindow(windowID))
  40. {
  41. AltTabTotalNum ++
  42. AltTabListID_%AltTabTotalNum% := windowID
  43. }
  44. }
  45. }
  46. }
  47.  
  48. IsInvisibleWin10BackgroundAppWindow(hWindow) {
  49. result := 0
  50. VarSetCapacity(cloakedVal, A_PtrSize) ; DWMWA_CLOAKED := 14
  51. hr := DllCall("DwmApi\DwmGetWindowAttribute", "Ptr", hWindow, "UInt", 14, "Ptr", &cloakedVal, "UInt", A_PtrSize)
  52. if !hr ; returns S_OK (which is zero) on success. Otherwise, it returns an HRESULT error code
  53. result := NumGet(cloakedVal) ; omitting the "&" performs better
  54. return result ? true : false
  55. }
  56.  
  57. Decimal_to_Hex(var)
  58. {
  59. SetFormat, integer, hex
  60. var += 0
  61. SetFormat, integer, d
  62. return var
  63. }
Add Comment
Please, Sign In to add comment