Jump to content

Recommended Posts

Posted

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.

Posted (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 by 636C65616E
Posted
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.

Posted (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 by 636C65616E
Posted (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 by 636C65616E

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
×
×
  • Create New...