mmwatson Posted May 19, 2014 Share Posted May 19, 2014 Greetings, 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> Opt("MustDeclareVars",1) ; 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". GUICtrlCreateListViewItem($aWindows[$i][0],$lstView) EndIf Next EndFunc Func isVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc ; 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" GUISetState(@SW_SHOW) While 1 Local $iMsg = GUIGetMsg() Sleep(50) If $iMsg = $GUI_EVENT_CLOSE Then ExitLoop EndIf WEnd Link to comment Share on other sites More sharing options...
JohnOne Posted May 19, 2014 Share Posted May 19, 2014 Start button and desktop they are. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
mmwatson Posted May 20, 2014 Author Share Posted May 20, 2014 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. MW 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