Jump to content

Recommended Posts

Posted

Hi,

I am new to AutoIt, I have a standalone GUI application containing a ListBox which which displays files in a directory at run time, I am able to get total count of items in the list box but not able to get individual item text. Please help on this.

Below is the code written

; Create a handle for list box

$hListBoxHandle = ControlGetHandle("", "", "ListBox3")

; Get Items count in the list box

$ItemsCount= _GUICtrlListBox_GetCount($hListBoxHandle )

MsgBox(0,"UI Listbox Items count",$ItemsCount)

; Loop through the no. of items in the listbox and display the item text

For $i = 0 To $ItemsCount Step 1

MsgBox(0,"Item Text", _GUICtrlListBox_GetText($hListBoxHandle , $i)

Next

AutoIt window Info of the control is attached.

post-63268-0-81314000-1298464031_thumb.j

Posted

The ListBox items are not selectable, items will be added/updated at run time too. User can only scroll up/down to view items added.

Ok !

So, why not use a ListView instead of ListBox ?

you could get text by _GUICtrlListView_GetItemText...Posted Image

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Posted

This is not a list-view control, autoit window info saying it is listbox control - CLASS: ListBox. How can I use ListView?

Even I tried using ListView control, now even item count is showing 0 and item text is displayed nothing during the loop.

; Create a handle for listview

$hListBoxHandle = ControlGetHandle("", "", "ListBox3")

; Get Items count in the list view

$ItemsCount= _GUICtrlListView_GetItemCount($hListBoxHandle )

MsgBox(0,"UI Listbox Items count",$ItemsCount)

; Loop through the no. of items in the listview and display the item text

For $i = 0 To $ItemsCount Step 1

MsgBox(0,"Item Text", _GUICtrlListView_GetItemText($hListBoxHandle , $i)

Next

Posted

Hi,

It is an AutoIt script only. I am writing in SciTi editor, Part of the script posted on the forum.

Is there any way to get the item text from the listbox? Please help me.

Posted (edited)

Ok

It is strange that you get the handle and the count of items without the title of the window and just the controlid !

There is really no title ?

try

ControlGetHandle ( "[CLASS:ListBox]", "", "ListBox3" )

Edit : i don't see any error in your script so i think that handle is bad.

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Posted

Window Title is the main application window which is there, to create the handle I am using ClassnameNN in place of controlID in ControlGetHandle funcion.

Tried this and no luck - ControlGetHandle ( "[CLASS:ListBox]", "", "ListBox3" ), no handle returned for the control.

Posted

Window Title is the main application window which is there, to create the handle I am using ClassnameNN in place of controlID in ControlGetHandle funcion.

Tried this and no luck - ControlGetHandle ( "[CLASS:ListBox]", "", "ListBox3" ), no handle returned for the control.

Can you try your method for see if there is an error.

$hListBoxHandle = ControlGetHandle("", "", "ListBox3")
ConsoleWrite ( "@error : " & @error & @Crlf )
ConsoleWrite ( "$hListBoxHandle : " & $hListBoxHandle & @Crlf )

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

  • Moderators
Posted

wakillon,

It is strange that you get the handle and the count of items without the title of the window and just the controlid !

If you do not enter "Title" and "text" parameters, AutoIt will usually (but not not guaranteed) default to the active window. so it is not really surprising. ;)

Sreekanth,

I am confused - although that is not difficult to do. :idiot:

Is the ListBox you are trying to read one created in another AutoIt script? Or is it in the same script in which you are trying to read the contents? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

wakillon,

If you do not enter "Title" and "text" parameters, AutoIt will usually (but not not guaranteed) default to the active window. so it is not really surprising. ;)

Sreekanth,

I am confused - although that is not difficult to do. :idiot:

Is the ListBox you are trying to read one created in another AutoIt script? Or is it in the same script in which you are trying to read the contents? :)

M23

@M23:

ListBox is not created in the autoit script i am writing, it is in a standalone win32 application. I am writing the script to test the controls and perform some actions on the controls like button clicking, reading listbox contents etc.

Posted (edited)

wakillon,

If you do not enter "Title" and "text" parameters, AutoIt will usually (but not not guaranteed) default to the active window. so it is not really surprising. :)

M23

I know this, but like i don't find errors in his script i thinked that handle was wrong.

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

  • Moderators
Posted

Sreekanth,

Are you sure that the GUI CLASS is "ListBox" - that sounds to me like the clas of the control of which your list is INSTANCE:3. :)

What does the Window Info tool tell you about the window CLASS? Perhaps you could post what you get in the Window and Control tabs of the tool so we can take a look. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

Sreekanth,

Are you sure that the GUI CLASS is "ListBox" - that sounds to me like the clas of the control of which your list is INSTANCE:3. :)

What does the Window Info tool tell you about the window CLASS? Perhaps you could post what you get in the Window and Control tabs of the tool so we can take a look. ;)

M23

@M23: Here is the info..

Class ListBox

Instance 3

ClassnameNN ListBox3

Advanced Mode [CLASS:ListBox; INSTANCE:3]

I have attached the screenshot of the Info tool in my first post.

  • Moderators
Posted

Sreekanth,

That is the info for the CONTROL - we also need the info for the WINDOW on the first tab of the tool.

M23

P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. :)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

This is not a list-view control, autoit window info saying it is listbox control - CLASS: ListBox. How can I use ListView?

Even I tried using ListView control, now even item count is showing 0 and item text is displayed nothing during the loop.

; Create a handle for listview

$hListBoxHandle = ControlGetHandle("", "", "ListBox3")

; Get Items count in the list view

$ItemsCount= _GUICtrlListView_GetItemCount($hListBoxHandle )

MsgBox(0,"UI Listbox Items count",$ItemsCount)

; Loop through the no. of items in the listview and display the item text

For $i = 0 To $ItemsCount Step 1

MsgBox(0,"Item Text", _GUICtrlListView_GetItemText($hListBoxHandle , $i)

Next

Thnx, good loop! (Y)
  • Moderators
Posted (edited)

Sreekanth,

OK, so now we try this and see what we get:

; Create a handle for list box - use full ID
$hListBoxHandle = ControlGetHandle("Sample Title", "", "[CLASS:ListBox;INSTANCE:3]")

; You can check with the Window Info tool to see if you get the correct handle
; If not then try [CLASS:#32770] in place of the title text

; Get Items count in the list box
$ItemsCount= _GUICtrlListBox_GetCount($hListBoxHandle )
MsgBox(0,"UI Listbox Items count",$ItemsCount)

; Loop through the no. of items in the listbox and display the item text
For $i = 0 To $ItemsCount Step 1
    MsgBox(0,"Item Text", _GUICtrlListBox_GetText($hListBoxHandle , $i) 
Next

Fingers crossed! :)

M23

Edit: Curly insted of straight bracket - sorry.

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...