Jump to content
Sign in to follow this  
JohnJF

Need help: _GUICtrlListBox_GetText not work correctly

Recommended Posts

JohnJF

I am using AutoIt to retrieve the text of a listbox control (contains a list of text items) in a 3rd party app. I've been able to get both the main window handle and the handle of the listbox, and I can also use ControlSend to select items in the listbox. However, calling the _GUICtrlListBox_GetText (from <GuiListBox.au3>) failed to get the text from the listbox, eg, in the following code:

Local $ret = WinExists($test_win_title, $test_win_text)

PrintLine("win exist: $ret$")

$ret = WinActivate($test_win_title, $test_win_text)

PrintLine("activate: $ret$")

WinWaitActive($test_win_title, $test_win_text, 1)

Local $listview_id = "[CLASS:ListBox; INSTANCE:1]"

Local $hwin = WinGetHandle($test_win_title, $test_win_text)

PrintLine("hwin handle: $hwin$")

Local $hlist = ControlGetHandle($hwin, "", $listview_id)

PrintLine("hlist handle: $hlist$")

Local $count = _GUICtrlListBox_GetCount($hlist)

PrintLine("count: $count$")

ConsoleWrite("first line:"&_GUICtrlListBox_GetText($hlist, 0)&@CRLF)

ConsoleWrite("2nd line:"&_GUICtrlListBox_GetText($hlist, 1)&@CRLF)

Func PrintLine($txt)

ConsoleWrite($txt&@CRLF)

EndFunc

Running the above, I get:

win exist: 1

activate: 0x02230466

hwin handle: 0x02230466

hlist handle: 0x01CB04EA

count: 8

first line:??

2nd line:??4??

Here the handles seem to be valid and the item count is also correct, but the return texts are garbage strings - they should be printable ASCII text.

Do I miss something in the above? How to fix the problem? Thanks a lot for help!

Share this post


Link to post
Share on other sites
Steveiwonder

_GUICtrlListBox_GetText Wont work with 3rd party applications, this is for a GUI create with Autoit.

If you wish to interact with 3rd party programs you can use something like ControlGetText or ControlCommand is probably what your looking for.

Check the helpfile click "Index" and just type "Control", should list a whole load of available functions.

GL

Steve

Edited by Steveiwonder

They call me MrRegExpMan

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.