Jump to content

WinList() don't work


Recommended Posts

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.

Link to comment
Share on other sites

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 by 636C65616E
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by 636C65616E
Link to comment
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
 Share

×
×
  • Create New...