XGamerGuide Posted August 12, 2021 Posted August 12, 2021 I'm trying to call WinList() with a handle. That should be possible: Quote The title/hWnd/class of the windows to get the list. But I only get back an 2d array that looks like this: --------- 0 | (That means no window was found.) It's not the window or the handle. When I call other functions like WinExists() or WinGetHandle() it works. Is it because of me, the description in the reference or because of Autoit who makes a mistake? No, because of the rest of my program I don't want to use WinGetTitle() because the format of WinList() has to be kept. Alternatively, I could create a 2d array myself, but it should also work with WinList() ... I hope.
636C65616E Posted August 13, 2021 Posted August 13, 2021 (edited) Tested a bit, and it appears that it returns an empty array ... Anyway, WinList returns an array of Title and hWnd. As an hwnd is unique, if you already know it, why do you need WinList ? Logically, passing an hwnd to WinList should return an array with only 1 entry ... 4 hours ago, XGamerGuide said: I don't want to use WinGetTitle() because the format of WinList() has to be kept I don't get the logic behind that statement ... func _WinList($arg, $text = '') if IsPtr($arg) or IsNumber($arg) then local $res = WinGetTitle($arg,$text) if $res == '' then local $ret = [[0,0]] return $ret endif local $ret = [[1,0],[$res,ptr($arg)]] return $ret endif return WinList($arg,$text) endfunc Edited August 13, 2021 by 636C65616E
XGamerGuide Posted August 13, 2021 Author Posted August 13, 2021 Quote Anyway, WinList returns an array of Title and hWnd. As an hwnd is unique, if you already know it, why do you need WinList ? My program is designed to process the output from a WinList() function. But there is an event in my program where the handle is used instead of the title. Of course I can also write my own function like you wrote one, but I was hoping that it would work without it.
XGamerGuide Posted August 13, 2021 Author Posted August 13, 2021 Quote if $res == '' then Besides, I think the title can also be empty: #include <Array.au3> _ArrayDisplay(WinList())
636C65616E Posted August 13, 2021 Posted August 13, 2021 (edited) WinGetTitle Quote Return Value Success: a string containing the complete window title. Failure: "" if the window is not found. But you're right in the sense of a window can have an empty title, was lazy, anyway just use GetWindowText ... Edited August 13, 2021 by 636C65616E
XGamerGuide Posted August 13, 2021 Author Posted August 13, 2021 Quote anyway just use GetWindowText The text can also be empty. For this you also have to use WinExists() to check whether the window exists.
636C65616E Posted August 13, 2021 Posted August 13, 2021 (edited) GetWindowTextA and GetWindowTextW The result only tells you if it fails or not, this is not about the text itself Just use the WinAPI : _WinAPI_GetWindowText EDIT1: Quote If the window has no title bar or text, if the title bar is empty, or if the window or control handle is invalid, the return value is zero Well, yeah check if the window exists, I'm really starting to be tired :/ EDIT2: nop $form = GUICreate('') $res = _WinAPI_GetWindowText($form) ConsoleWrite(_WinAPI_GetLastError() & ': ' & _WinAPI_GetLastErrorMessage() & @CRLF) ConsoleWrite('title: "' & $res & '"' & @CRLF) GUIDelete($form) $res = _WinAPI_GetWindowText(0) ConsoleWrite(_WinAPI_GetLastError() & ': ' & _WinAPI_GetLastErrorMessage() & @CRLF) ConsoleWrite('title: "' & $res & '"' & @CRLF) just check the last error Edited August 13, 2021 by 636C65616E
XGamerGuide Posted August 13, 2021 Author Posted August 13, 2021 That's all you need for it: If WinExists($p) Then $ret = WinGetTitle($p) EndIf I can manage my own function that turns it into a 2d array, but my question was why it doesn't work with WinList(), although it should actually work.
636C65616E Posted August 13, 2021 Posted August 13, 2021 I was digin a bit, but as it is agains EULA to reverse I will not explore futher. But as far as I've seen (without breaking the EULA) it may be an internal bug.
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