HurleyShanabarger Posted January 25, 2022 Share Posted January 25, 2022 (edited) Hello, I am writing an UDF which uses WinList. The title-parameter is taken from the function call of the UDF. If the title-parameter is blank WinList("") or default WinList(Default) the function returns something different, as if called using this WinList() Is it possible to have the same output as in the third example? This is the code I am using (reduced to the core): #Region Includes #include <Array.au3> #EndRegion Includes #Region Main _Main() Func _Main() Local $arWinList ; Return WinList with all windows $arWinList = WinList() _ArrayDisplay($arWinList) ; Returns WinList with only - in my case - scite window from the script $arWinList = _WinListWrapper("") _ArrayDisplay($arWinList) EndFunc ;==>_Main #EndRegion Main #Region Functions Func _WinListWrapper($sgTitle = "") Return WinList($sgTitle) EndFunc #EndRegion Functions Edited January 25, 2022 by HurleyShanabarger Link to comment Share on other sites More sharing options...
ad777 Posted January 25, 2022 Share Posted January 25, 2022 (edited) @HurleySh. you can use EnumWindows s it possible to have the same output as in the third example? #include <Array.au3> #include <WinAPISysWin.au3> Local $aWindows = _WinAPI_EnumWindows(False) Local $aResult[$aWindows[0][0]][5] For $i = 1 To $aWindows[0][0] $aResult[$i - 1][0] = $aWindows[$i][0] $aResult[$i - 1][1] = WinGetTitle($aWindows[$i][0]) Next _ArrayDisplay($aResult, "_WinAPI_EnumWindows") Edited January 25, 2022 by ad777 iam ِAutoit programmer. best thing in life is to use your Brain to Achieve everything you want. Link to comment Share on other sites More sharing options...
HurleyShanabarger Posted January 25, 2022 Author Share Posted January 25, 2022 Issue there is, that _WinAPI_EnumWindows does not return all windows but the visible ones only. Link to comment Share on other sites More sharing options...
ad777 Posted January 25, 2022 Share Posted January 25, 2022 @HurleyShanabarger _WinAPI_EnumWindows Enumerates all windows: _WinAPI_EnumWindows ( [$bVisible = True [, $hWnd = Default]] ) Parameters $bVisible [optional] Window selection flag: True - Returns only visible windows False - Returns all windows $hWnd [optional] Handle of the starting windows (default Desktop windows) iam ِAutoit programmer. best thing in life is to use your Brain to Achieve everything you want. Link to comment Share on other sites More sharing options...
Luke94 Posted January 25, 2022 Share Posted January 25, 2022 WinList: Quote If no title and text is given then all top-level windows are returned. You might want _WinAPI_EnumDesktopWindows instead of _WinAPI_EnumWindows. Quote _WinAPI_EnumDesktopWindows Enumerates all top-level windows associated with the specified desktop Link to comment Share on other sites More sharing options...
Solution HurleyShanabarger Posted January 25, 2022 Author Solution Share Posted January 25, 2022 @ad777, sorry I mixed _WinAPI_EnumWindows with _WinAPI_EnumWindowsTop. @Luke94, I use _WinAPI_EnumDesktopWindows like this, I get the same result as WinList, but without the option to filter for title/name: _WinAPI_EnumDesktopWindows(_WinAPI_GetThreadDesktop(_WinAPI_GetCurrentThreadId()), False) My solution for now is this: Func _WinList($vWndw = "", $sgText = "") Return ($sgText Or $vWndw) ? WinList($vWndw, $sgText) : WinList() EndFunc ;==>_WinList Still feels like a bug, that if use "", Default, -1 or Null WinList is returning something different. Link to comment Share on other sites More sharing options...
Danp2 Posted January 25, 2022 Share Posted January 25, 2022 1 hour ago, HurleyShanabarger said: Still feels like a bug, that if use "", Default, -1 or Null WinList is returning something different. A similar discussion occurred recently, but regarding ProcessList -- HurleyShanabarger 1 Latest Webdriver UDF Release Webdriver Wiki FAQs 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