Sandhya Posted August 18, 2015 Posted August 18, 2015 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
SupaNewb Posted August 18, 2015 Posted August 18, 2015 From the help file: ControlGetTextExample() 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 ;==>ExampleYou 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?
Sandhya Posted August 19, 2015 Author Posted August 19, 2015 From the CLASS:Edit, we can retreive the text using ControlGetText. But here, my class is listbox.
SupaNewb Posted August 19, 2015 Posted August 19, 2015 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.
Sandhya Posted August 19, 2015 Author Posted August 19, 2015 I am able to get the Handle for that listbox. Using that also, I am not getting the text.
Moderators JLogan3o13 Posted August 19, 2015 Moderators Posted August 19, 2015 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 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Sandhya Posted August 20, 2015 Author Posted August 20, 2015 (edited) This is the info for that window.>>>> Window <<<<Title: Flow MonitorClass: IDM_FrameWindowPosition: 755, 84Size: 535, 340Style: 0x16CF0000ExStyle: 0x00000100Handle: 0x000000000237089A>>>> Control <<<<Class: ListBoxInstance: 1ClassnameNN: ListBox1Name: Advanced (Class): [CLASS:ListBox; INSTANCE:1]ID: 4112Text: Position: 6, 6Size: 508, 132ControlClick Coords: 111, 69Style: 0x54A01511ExStyle: 0x00000200Handle: 0x00000000003B080E>>>> Mouse <<<<Position: 125, 125Cursor ID: 0Color: 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 August 20, 2015 by Sandhya
SupaNewb Posted August 20, 2015 Posted August 20, 2015 Try thisLocal $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)
SupaNewb Posted August 20, 2015 Posted August 20, 2015 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 commanduntil the problem is isolated. There is actually a nifty tool in Scite(Debug To Console) that speeds up thisprocess. That combined with the help file is usually all that is needed.
Sandhya Posted August 21, 2015 Author Posted August 21, 2015 it returnedHandle: 0x0237089A Error Code: 0Text: Error Code: 0
SupaNewb Posted August 21, 2015 Posted August 21, 2015 #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
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