spinal Posted August 3 Share Posted August 3 I am trying to create a list of running programs, similar the the alt+tab switcher in windows. The following is close, but it lists some programs that windows does not. Are there any criteria I am missing when creating the list? #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> ; Get a list of all open windows Local $aWindows = WinList() ; Initialize an array to hold titles of windows that would show in Alt + Tab Local $sVisibleTitles = "" ; Loop through each window For $i = 1 To $aWindows[0][0] ; Skip windows without a title and the desktop window If $aWindows[$i][0] = "" Or $aWindows[$i][1] = 0 Then ContinueLoop ; Retrieve the window handle Local $hWnd = $aWindows[$i][1] ; Get the window state Local $iState = WinGetState($hWnd) ; Retrieve window state ; Check if the window is visible (not minimized and not hidden) If BitAND($iState, 2) Then ; Concatenate the window title to the visible titles string $sVisibleTitles &= "Window Title: " & $aWindows[$i][0] & ", State: " & $iState & @CRLF EndIf Next ; Display visible windows in a message box If $sVisibleTitles = "" Then MsgBox($MB_ICONINFORMATION, "Visible Windows", "No visible windows found.") Else MsgBox($MB_ICONINFORMATION, "Visible Windows", $sVisibleTitles) EndIf Thanks. Link to comment Share on other sites More sharing options...
Solution lIlIIlIllIIIIlI Posted August 4 Solution Share Posted August 4 Try this expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WinAPI.au3> #include <Array.au3> const $WS_VISIBLE = 0x10000000 const $WS_EX_APPWINDOW = 0x00040000 const $WS_EX_TOOLWINDOW = 0x00000080 Local $aWindows = WinList() Local $sVisibleTitles = "" For $i = 1 To $aWindows[0][0] If $aWindows[$i][0] = "" Or $aWindows[$i][1] = 0 or not checkwindow($aWindows[$i][1]) Then ContinueLoop Local $hWnd = $aWindows[$i][1] Local $iState = WinGetState($hWnd) If BitAND($iState, 2) Then $sVisibleTitles &= "Window Title: " & $aWindows[$i][0] & ", State: " & $iState & @CRLF EndIf Next If $sVisibleTitles = "" Then MsgBox($MB_ICONINFORMATION, "Visible Windows", "No visible windows found.") Else MsgBox($MB_ICONINFORMATION, "Visible Windows", $sVisibleTitles) EndIf Func checkwindow($hWnd) If Not BitAND(_WinAPI_GetWindowLong($hWnd, $GWL_STYLE), $WS_VISIBLE) Then Return False If BitAND(_WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE), $WS_EX_TOOLWINDOW) Then Return False If Not _WinAPI_GetParent($hWnd) And Not BitAND(_WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE), $WS_EX_TOOLWINDOW) Then Return True Return False EndFunc Link to comment Share on other sites More sharing options...
spinal Posted August 4 Author Share Posted August 4 Much better! Thanks 🙂 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now