Jump to content
Sign in to follow this  

non-visible windows listed even when filtered for visibility

Recommended Posts


I am working on a small utility to simplify moving open windows from one monitor to another. I've run into something a bit odd.  When I filter the output of WinList() using a WinGetState() of 2 ("window is visible") and output the entire list to a GUI, I do see the visible windows, but I also always see at least two that aren't. One is named "Start" and the other is named "Program manager". I would like to understand where these two entries - which don't correspond to any open windows that I see - are coming from. 

I imagine I'm missing something really basic. I suppose I could add a window title filter, but I'd rather understand why those two non-visible windows are showing up even when I do a BitAnd of 2 with the WinGetState() of each window in the isVisible() user-defined function. Any insights another autoit user might be able to offer would be most welcome.

My code:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
; Windows states are retuned by WinGetState:
; 1 = window exists
; 2 = window is visible
; 4 = window is enabled
; 8 = window is active
; 16 = window is minimized
; 32 = window is maximized
Func populateList($aWindows)
  For $i = 1 to $aWindows[0][0]
    If $aWindows[$i][0] <> "" And isVisible($aWindows[$i][1]) Then
      ; For some reason, the program consistently lists at least two windows that aren't visible.
      ; They have windows titles "Start" and "Program Manager". 
Func isVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
    Return 0
; Main
Local $hWinMain = GUICreate("Open Windows",600,350)
Local $lstView = GUICtrlCreateListView("Open Windows",10,10,550,250)
Local $aWindows = WinList()
populateList($aWindows) ; The listView does contain all visible windows, but also contains
                                        ; two that I don't see: "Program Manager" and "Start"
While 1
  Local $iMsg = GUIGetMsg()
  If $iMsg = $GUI_EVENT_CLOSE Then

Share this post

Link to post
Share on other sites

I wondered whether that might be the case. If so, I suppose there's no way for me to exclude them short of filtering by title - which is, at least, easy enough. Thanks for posting.


Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...