Some people have reported issue with the GetListItem command failing to work with some applications. While we investigate the issues we’ve created a small workaround. This is a .Net tool called ListInspector. It’s a command line tool which you can pass a listbox handle to and it will dump out a list of all the items and their indexes.
Here’s an example of use:
//get handle of putty and find handle of listbox
//run ListInspector to get a list of items
Run>cmd.exe /C "%SCRIPT_DIR%\ListInspector.exe" %hWnd% > %TEMP_DIR%\items.txt
//find the index of the item we want
MessageModal>Index of %item_required% is %index%
The script here gets the items of the session selection box in the Putty SSH client. The first thing it does is get Putty’s window handle, then find the handle of the list box we want to inspect. It then runs ListInspector.exe and passes the listbox handle to it, piping the results to a temporary file. It then reads in the file and uses a RegEx to extract the index for the item we are looking for.
This is useful for those listboxes which don’t allow us to “drill down” properly and where the items and order of items may be dynamic, leaving us with no easy way to automate the selection of an item. Using ListInspector we can get the item’s index and then we know how many times we need to “Press Down” (first using Home to make sure we’re at the top).
You can download ListInspector here. The zip file contains the example script and a small readme file. .Net 2.5 or higher is required.