Jump to content

No response from tree structured, multi-select listbox


pps
 Share

Recommended Posts

ListLBox_SelectString.au3I am trying to drive an application through AutoIt 3. I got pretty far, but on one screen I can’t select in a listbox and also not in a combobox. The combobox is not that important as currently it shows only one item and hence this is in the edit field of the combo as needed.

The listbox has $LBS_EXTENDEDSEL style and also a tree structure with a single folder level. In my case there is only one folder. Manually, using the + respectively the - in front of the folder name, the folder can be expanded and collapsed. When the window pops up my folder is already expanded. The AutoIt Window Info shows

Style: 0x94C800C4

ExStyle: 0x00010101

Another spy, RanorexSpy, shows the Style as 0x50310409, “focusable,selectable,multiple selectable”.

I tried _GUICtrlListBox_FindString() and _GUICtrlComboBox_FindStringExact() . Both return 0 although the matching item must have an index of 10 or so. @error is also 0. Same with _GUICtrlListBox_SelectString() while of course it is documented that this function is not valid for $LBS_EXTENDEDSEL style.

As I couldn’t make it with an existing function I am now trying to determine the length of the list, looping through the items, and doing the matching myself. In the loop I tried

$itemVal = _GUICtrlListBox_GetItemData($handle,$i) and

$itemVal = _GUICtrlListBox_GetText($handle,$i) before matching $itemVal and upon success calling _GUICtrlListBox_SetCurSel($handle,$i) or _GUICtrlListBox_ClickItem($handle,$i) .

But _GUICtrlListBox_GetItemData() returns 0 and _GUICtrlListBox_GetText() returns a single L for every index into the list.

Already determining the size of the list fails: _GUICtrlListBox_GetCount() returns 0 although the list has more items than fit into the visible part of the listbox, i.e. scrolling is required.

Just for test purpose I tried also selecting an item without having its index searched: _GUICtrlListBox_SetSel ($handle, 2) , however no effect.

I have the proof that in general access to the window containing the listbox and combox controls, does work: a call to ControlClick() before trying to access combo and listbox successfully changes a radio button.

I am on Windows 7 x64.

Anyone has a hint for me?

Link to comment
Share on other sites

See the screenshot for a better impression of the window with the tree structured multi-select listbox:

Posted Image

The item I need to select has an index > 6 and requires scrolling.

Using AutoIt Window Info I cannot get the text of the items in the list - here shown as Anonymised 1... AutoIt Window Info says Text = "List 1" wherever I place the cursor in the listbox. RanorexSpy however is capable of reading the text of each item when the cursor is placed over the item. So it is possible to drive the control programmatically. I just wonder whether it is possible with AutoIt.

Link to comment
Share on other sites

Tried now some more combinations, including the basic

ControlCommand ( $window, $windowText, $controlID, "SelectString", $selectString )

None of shows any impact on the listbox.

Is there anybody who can tell me if its worthless to try any further?

Func ListLBox_SelectString($window, $windowText, $controlID, $selectString, $fPartialOK = True)
; Searching $selectString in the specified listbox. If found, click it and return True, else False

_DebugOut("Entering Func ListLBox_SelectString(" & $window & ", " & $windowText & ", " & $controlID & ", " & $selectString & ", " & $fPartialOK & ")")
    $returnVal=False
    $handle=ControlGetHandle($window, $windowText, $controlID)
_DebugOut("$handle = " & $handle)
;Find selectString and select
$i=0
;; $Debug_LB = True
$listEnd = _GUICtrlListBox_GetCount ($handle) - 1
;; $Debug_LB = False
_DebugOut("_GUICtrlListBox_GetCount ($handle) = " & $listEnd + 1)
_DebugOut("_GUICtrlListBox_GetTopIndex ($handle) = " & _GUICtrlListBox_GetTopIndex ($handle))
_DebugOut("_GUICtrlListBox_GetListBoxInfo ($handle) = " & _GUICtrlListBox_GetListBoxInfo ($handle))
; Select the range of items 2+1 through 3+1
_DebugOut("launching   _GUICtrlListBox_SelItemRange ($handle, 2, 3)")
_GUICtrlListBox_SelItemRange ($handle, 2, 3)
If $debugDestinationType=1 Then Sleep(3000)
; Select the item 2+1
_DebugOut("launching   _GUICtrlListBox_SetSel ($handle, 2)")
_GUICtrlListBox_SetSel ($handle, 2)
If $debugDestinationType=1 Then Sleep(3000)
; Click the item 4+1
_DebugOut("launching   _GUICtrlListBox_ClickItem  ($handle, 4, ""left"", False, 1)")
_GUICtrlListBox_ClickItem  ($handle, 4, "left", False, 1)
If $debugDestinationType=1 Then Sleep(3000)
; Double click the item 4+1 . If effective it would select the item and bring us to the next window of the wizard
_DebugOut("launching   _GUICtrlListBox_ClickItem  ($handle, 4, ""left"", False, 2)")
_GUICtrlListBox_ClickItem  ($handle, 4, "left", False, 2)
If $debugDestinationType=1 Then Sleep(3000)
; Perform command "SelectString" on the control
_DebugOut("launching   ControlCommand ( $window, $windowText, $controlID, ""SelectString"", $selectString )")
_DebugOut("         ControlCommand ( " & $window & ", " & $windowText & ", " & $controlID & ", ""SelectString"", " & $selectString & " )")
ControlCommand ( $window, $windowText, $controlID, "SelectString", $selectString )
If $debugDestinationType=1 Then Sleep(3000)
    ; Try also with text "List1" cleared
_DebugOut("launching   ControlCommand ( $window, "", $controlID, ""SelectString"", $selectString )")
_DebugOut("         ControlCommand ( " & $window & ", """", " & $controlID & ", ""SelectString"", " & $selectString & " )")
ControlCommand ( $window, "", $controlID, "SelectString", $selectString )
If $debugDestinationType=1 Then Sleep(3000)
    ; Try the same with all arguments as literals
_DebugOut("launching   ControlCommand ( ""Check-out Wizard - Step 1"", ""List1"", 2104, ""SelectString"", ""TRIF_Community_Model"")")
ControlCommand ( "Check-out Wizard - Step 1", "List1", 2104, "SelectString", "TRIF_Community_Model" )
If $debugDestinationType=1 Then Sleep(3000)
    ; Try the same with all arguments as literals and Text cleared
_DebugOut("launching   ControlCommand ( ""Check-out Wizard - Step 1"", """", 2104, ""SelectString"", ""TRIF_Community_Model"")")
ControlCommand ( "Check-out Wizard - Step 1", "", 2104, "SelectString", "TRIF_Community_Model" )
If $debugDestinationType=1 Then Sleep(3000)
; If $listEnd = -1 Then $listEnd = 20
While($i<=$listEnd AND NOT $returnVal)
  $itemVal = _GUICtrlListBox_GetItemData($handle,$i)
  _DebugOut("$itemVal = " & $itemVal)
  $itemVal = _GUICtrlListBox_GetText($handle,$i)
  _DebugOut("$itemVal = " & $itemVal)
  If (((StringInStr($itemVal, $selectString)>0) AND $fPartialOK) Or((StringCompare($itemVal, $selectString)=0) AND NOT $fPartialOK))  Then
   _DebugOut("launching   _GUICtrlListBox_SetCurSel(" & $handle & ", " & $i & ")")
   _GUICtrlListBox_SetCurSel($handle,$i)
   If $debugDestinationType=1 Then Sleep($msecSleepToAllowWatching)
   _DebugOut("launching   _GUICtrlListBox_SetCurSel(" & $handle & ", " & $i & ")")
   _GUICtrlListBox_ClickItem($handle,$i)
   If $debugDestinationType=1 Then Sleep($msecSleepToAllowWatching)
   $returnVal=True
  EndIf
  $i=$i+1
WEnd
    Return $returnVal
EndFunc ; ListLBox_SelectString()
Link to comment
Share on other sites

Sorry for the tabs. Here the same with spaces.

Func ListLBox_SelectString($window, $windowText, $controlID, $selectString, $fPartialOK = True)
    ; Searching $selectString in the specified listbox. If found, click it and return True, else False
   
    _DebugOut("Entering Func ListLBox_SelectString(" & $window & ", " & $windowText & ", " & $controlID & ", " & $selectString & ", " & $fPartialOK & ")")
    $returnVal=False
    $handle=ControlGetHandle($window, $windowText, $controlID)
    _DebugOut("$handle = " & $handle)
    ;Find selectString and select
    $i=0
;; $Debug_LB = True
    $listEnd = _GUICtrlListBox_GetCount ($handle) - 1
;; $Debug_LB = False
    _DebugOut("_GUICtrlListBox_GetCount ($handle) = " & $listEnd + 1)
    _DebugOut("_GUICtrlListBox_GetTopIndex ($handle) = " & _GUICtrlListBox_GetTopIndex ($handle))
    _DebugOut("_GUICtrlListBox_GetListBoxInfo ($handle) = " & _GUICtrlListBox_GetListBoxInfo ($handle))
    ; Select the range of items 2+1 through 3+1
    _DebugOut("launching   _GUICtrlListBox_SelItemRange ($handle, 2, 3)")
    _GUICtrlListBox_SelItemRange ($handle, 2, 3)
    If $debugDestinationType=1 Then Sleep(3000)
    ; Select the item 2+1
    _DebugOut("launching   _GUICtrlListBox_SetSel ($handle, 2)")
    _GUICtrlListBox_SetSel ($handle, 2)
    If $debugDestinationType=1 Then Sleep(3000)
    ; Click the item 4+1
    _DebugOut("launching   _GUICtrlListBox_ClickItem  ($handle, 4, ""left"", False, 1)")
    _GUICtrlListBox_ClickItem  ($handle, 4, "left", False, 1)
    If $debugDestinationType=1 Then Sleep(3000)
    ; Double click the item 4+1 . If effective it would select the item and bring us to the next window of the wizard
    _DebugOut("launching   _GUICtrlListBox_ClickItem  ($handle, 4, ""left"", False, 2)")
    _GUICtrlListBox_ClickItem  ($handle, 4, "left", False, 2)
    If $debugDestinationType=1 Then Sleep(3000)
    ; Perform command "SelectString" on the control
    _DebugOut("launching   ControlCommand ( $window, $windowText, $controlID, ""SelectString"", $selectString )")
    _DebugOut("         ControlCommand ( " & $window & ", " & $windowText & ", " & $controlID & ", ""SelectString"", " & $selectString & " )")
    ControlCommand ( $window, $windowText, $controlID, "SelectString", $selectString )
    If $debugDestinationType=1 Then Sleep(3000)
    ; Try also with text "List1" cleared
    _DebugOut("launching   ControlCommand ( $window, "", $controlID, ""SelectString"", $selectString )")
    _DebugOut("         ControlCommand ( " & $window & ", """", " & $controlID & ", ""SelectString"", " & $selectString & " )")
    ControlCommand ( $window, "", $controlID, "SelectString", $selectString )
    If $debugDestinationType=1 Then Sleep(3000)
    ; Try the same with all arguments as literals
    _DebugOut("launching   ControlCommand ( ""Check-out Wizard - Step 1"", ""List1"", 2104, ""SelectString"", ""TRIF_Community_Model"")")
    ControlCommand ( "Check-out Wizard - Step 1", "List1", 2104, "SelectString", "TRIF_Community_Model" )
    If $debugDestinationType=1 Then Sleep(3000)
    ; Try the same with all arguments as literals and Text cleared
    _DebugOut("launching   ControlCommand ( ""Check-out Wizard - Step 1"", """", 2104, ""SelectString"", ""TRIF_Community_Model"")")
    ControlCommand ( "Check-out Wizard - Step 1", "", 2104, "SelectString", "TRIF_Community_Model" )
    If $debugDestinationType=1 Then Sleep(3000)
    ; If $listEnd = -1 Then $listEnd = 20
    While($i<=$listEnd AND NOT $returnVal)
        $itemVal = _GUICtrlListBox_GetItemData($handle,$i)
        _DebugOut("$itemVal = " & $itemVal)
        $itemVal = _GUICtrlListBox_GetText($handle,$i)
        _DebugOut("$itemVal = " & $itemVal)
        If (((StringInStr($itemVal, $selectString)>0) AND $fPartialOK) Or((StringCompare($itemVal, $selectString)=0) AND NOT $fPartialOK))  Then
            _DebugOut("launching   _GUICtrlListBox_SetCurSel(" & $handle & ", " & $i & ")")
            _GUICtrlListBox_SetCurSel($handle,$i)
            If $debugDestinationType=1 Then Sleep($msecSleepToAllowWatching)
            _DebugOut("launching   _GUICtrlListBox_SetCurSel(" & $handle & ", " & $i & ")")
            _GUICtrlListBox_ClickItem($handle,$i)
            If $debugDestinationType=1 Then Sleep($msecSleepToAllowWatching)
            $returnVal=True
        EndIf
        $i=$i+1
    WEnd
    Return $returnVal
EndFunc ; ListLBox_SelectString()

Is it worth trying further or is this a control AutoIt 3.3.6.1 is not capable of?

Link to comment
Share on other sites

Good point AdmiralAlkex, I didn't try this earlier. Now, I tried

$handle=ControlGetHandle($window, $windowText, $controlID)
    _DebugOut("$handle = " & $handle)
   
    $index = _GUICtrlListView_FindText ($handle, $selectString)
    _DebugOut("Result of calling   _GUICtrlListView_FindText ($handle, $selectString) : " & $index)
   
    $index = _GUICtrlListView_FindInText ($handle, $selectString)
    _DebugOut("Result of calling   _GUICtrlListView_FindInText ($handle, $selectString) : " & $index)
   
    $tFindInfo = DllStructCreate($tagLVFINDINFO)
    DllStructSetData($tFindInfo, "Flags", $LVFI_STRING)
    $index = _GUICtrlListView_FindItem($handle, -1, $tFindInfo, $selectString)
    _DebugOut("Result of calling   _GUICtrlListView_FindItem($handle, -1, $tFindInfo, $selectString) : " & $index)

But this is still not successful. I am getting:

$handle = 0x00000000004008B2

Result of calling _GUICtrlListView_FindText ($handle, $selectString) : 4294967295

Result of calling _GUICtrlListView_FindInText ($handle, $selectString) : -1

Result of calling _GUICtrlListView_FindItem($handle, -1, $tFindInfo, $selectString) : 4294967295

4294967295 is 2 ** 32 - 1 , so rather a type conversion bug than an index to my list.

I wonder whether the handle to the SysListView32 instance is correct. AutoIt Window Info highlights the whole tree structure thing with surrounding scrollbars for this handle respective ID. Could it be the case that this control is composed of multiple controls where the list is just one of them, so the list would have its own handle?

Link to comment
Share on other sites

_GUICtrlListView_HitTest($handle) and _GUICtrlListView_SubItemHitTest($handle) are successful with the list. The code

MsgBox(0, "AutoIt", "Now 5 secs to position the cursor over an item in the list", 5)
    $result = _GUICtrlListView_HitTest($handle)
    $i = 1
    For $r In $result
        _DebugOut("Result of calling   _GUICtrlListView_HitTest($handle, 3) : [" & $i & "]: " & $r)
        $i += 1
    Next

results in:

Result of calling _GUICtrlListView_HitTest($handle, 3) : [1]: 2

Result of calling _GUICtrlListView_HitTest($handle, 3) : [2]: False

Result of calling _GUICtrlListView_HitTest($handle, 3) : [3]: True

Result of calling _GUICtrlListView_HitTest($handle, 3) : [4]: True

Result of calling _GUICtrlListView_HitTest($handle, 3) : [5]: True

Result of calling _GUICtrlListView_HitTest($handle, 3) : [6]: True

Result of calling _GUICtrlListView_HitTest($handle, 3) : [7]: True

Result of calling _GUICtrlListView_HitTest($handle, 3) : [8]: False

Result of calling _GUICtrlListView_HitTest($handle, 3) : [9]: False

Result of calling _GUICtrlListView_HitTest($handle, 3) : [10]: False

But how can I read from the list?

I tried

$result = _GUICtrlListView_GetItem($handle, 3)
    $i = 1
    For $r In $result
        _DebugOut("Result of calling   _GUICtrlListView_GetItem($handle, 3) : [" & $i & "]: " & $r)
        $i += 1
    Next

But that does not return a useful result:

Result of calling _GUICtrlListView_GetItem($handle, 3) : [1]:

Result of calling _GUICtrlListView_GetItem($handle, 3) : [2]: 0

Result of calling _GUICtrlListView_GetItem($handle, 3) : [3]: 0

Result of calling _GUICtrlListView_GetItem($handle, 3) : [4]:

Result of calling _GUICtrlListView_GetItem($handle, 3) : [5]: 0

Result of calling _GUICtrlListView_GetItem($handle, 3) : [6]: 0

Result of calling _GUICtrlListView_GetItem($handle, 3) : [7]: 0

Result of calling _GUICtrlListView_GetItem($handle, 3) : [8]: 0

[3] should contain the item text.

Link to comment
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
 Share

  • Recently Browsing   0 members

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