Sandhya

Activate and read from listbox

13 posts in this topic

I need to read text from listbox. I used ControlGetText ( "Flow Monitor", "", "[ID:1006]")

Also I have used ControlListView ( "Flow Monitor", "", "[ID:1006]", "GetText")

Nothing worked. What went wrong?

Also, is it posible to get text from already existing GUI using

_GUICtrlListBox_GetText

 

Share this post


Link to post
Share on other sites



From the help file: ControlGetText

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10);this is one way to obtain the Notepad Window/GUI handle

    ; Set the edit control in Notepad with some text. The handle returned by WinWait is used for the "title" parameter of ControlSetText.
    ControlSetText($hWnd, "", "Edit1", "This is some text")

    ; Retrieve the text of the edit control in Notepad. The handle returned by WinWait is used for the "title" parameter of ControlGetText.
    Local $sText = ControlGetText($hWnd, "", "Edit1")

    ; Display the text of the edit control.
    MsgBox($MB_SYSTEMMODAL, "", "The text in Edit1 is: " & $sText)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example

You will get more help here by posting the actual code that you have tried. Once you obtain the GUI/Window handle that contains the control/s you want to interact with, the problem is half solved. Are you able to retrieve/obtain the GUI handle?

Share this post


Link to post
Share on other sites

From the CLASS:Edit, we can retreive the text using ControlGetText. But here, my class is listbox.

 

Share this post


Link to post
Share on other sites

From the CLASS:Edit, we can retreive the text using ControlGetText. But here, my class is listbox.

 

[CLASS:ListBox; INSTANCE:1] if the Windows ListBox is the first instance. There is a GuiListBox UDF. You will need to know the ListBox control ID or it's handle.

Share this post


Link to post
Share on other sites

I am able to get the Handle for that listbox. Using that also, I am not getting the text.

Share this post


Link to post
Share on other sites

Sandhya, how about posting your code so we can see what you're attempting to do. Otherwise, we're simply guessing. Help us help you ;)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

This is the info for that window.

>>>> Window <<<<
Title:    Flow Monitor
Class:    IDM_FrameWindow
Position:    755, 84
Size:    535, 340
Style:    0x16CF0000
ExStyle:    0x00000100
Handle:    0x000000000237089A

>>>> Control <<<<
Class:    ListBox
Instance:    1
ClassnameNN:    ListBox1
Name:    
Advanced (Class):    [CLASS:ListBox; INSTANCE:1]
ID:    4112
Text:    
Position:    6, 6
Size:    508, 132
ControlClick Coords:    111, 69
Style:    0x54A01511
ExStyle:    0x00000200
Handle:    0x00000000003B080E

>>>> Mouse <<<<
Position:    125, 125
Cursor ID:    0
Color:    0xFFFFFF

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

Some text are present in the listbox, I need to read it.

My code is

 Local $hWnd = WinGetHandle("[CLASS:IDM_FrameWindow; INSTANCE:1]")

Local $sText = ControlGetText("Flow Monitor", "", 4112)

MsgBox($MB_SYSTEMMODAL, "", "The text is: " & $sText)

But it returned nothing.

Edited by Sandhya

Share this post


Link to post
Share on other sites

Try this

Local $sText = ControlGetText("Flow Monitor", "", "[CLASS:ListBox; INSTANCE:1]")

If no good, try this to see what is returning in the console

#include <MsgBoxConstants.au3>
Local $hWnd = WinGetHandle("[CLASS:IDM_FrameWindow; INSTANCE:1]")
ConsoleWrite("Handle: " & $hWnd & @TAB & "Error Code: " & @error & @CRLF)
Local $sText = ControlGetText("Flow Monitor", "", "[CLASS:ListBox; INSTANCE:1]")
ConsoleWrite("Text: " & $sText & @TAB & "Error Code: " & @error & @CRLF)
MsgBox($MB_SYSTEMMODAL, "", "The text is: " & $sText)

 

 

 

Share this post


Link to post
Share on other sites

Sorry.. No result from this as well.

Share this post


Link to post
Share on other sites

No result? What does it return in the console(the lower pane in Scite) when you run your code?

If ControlGetText fails, it sets the @error flag to 1. That is why I included @error in the ConsoleWrite.

When my code doesn't work or return as expected, I start console writing the output of each command

until the problem is isolated. There is actually a nifty tool in Scite(Debug To Console) that speeds up this

process. That combined with the help file is usually all that is needed. :)

Share this post


Link to post
Share on other sites

it returned

Handle: 0x0237089A    Error Code: 0
Text:     Error Code: 0

 

Share this post


Link to post
Share on other sites
#include <GuiListBox.au3>

__GetAllListBoxText()

Func __GetAllListBoxText()
    Local $hListBox, $iItemCount, $sText
    $hListBox = ControlGetHandle("Flow Monitor", "", "[CLASS:ListBox; INSTANCE:1]")
    $iItemCount = _GUICtrlListBox_GetCount($hListBox)
    For $i = 0 To $iItemCount - 1
        $sText = _GUICtrlListBox_GetText($hListBox,$i)
        ConsoleWrite("Index: " & $i & @TAB & "Text String: " & $sText & @CRLF)
    Next
EndFunc   ;==>__GetAllListBoxText

 

Share this post


Link to post
Share on other sites

this also didn't help.

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