Jump to content

Recommended Posts

Posted

I'm trying to automate testing of a PC Client from a 3rd party vendor - unfortunately I can't give many specifics.

An example window has an area up top with filters/controls, and a grid/table below with data on current orders to be processed. I'm trying to interact with the table, to select specific orders/rows.

When I drag the "Finder Tool" over to the table, it selects (black outline) the table as a whole, as a single control. Basic Control Info, Class= "WindowsForms10.SysListView32.app.0.141b42a_r9_ad1", Instance = "1". The table column headers are a separate control Class= "SysHeader32" Instance= "1".

I'm not sure if I can interact with specific rows or query the info on the screen. In the info tab, when I select either of these controls, the "Visible Text" tab only contains text from the filters/controls above the table, not the table itself. Same with the "Hidden Text" tab, which only has 1 entry. None of the column names nor the table data appears to be visible to the Info tool.

The only thing that changes when I drag "Finder Tool" over the various rows/columns is the x/y ControlClick Coords, and that's no especially helpful for what I need to do.

Am I missing something? I'm worried I might just need to go back to the drawing board with a different tool.

 

  • 1 month later...
Posted

Nine, thanks for the pointer - took me a bit to get back to this project, but I've now tried all I can think of with the ListView GUI functions. I'm able to return correct row and column counts, but that's it. Am I using any of these functions incorrectly? Are there any functions or ways to call them that I'm overlooking (like a way to return properties of a sub-item aside from Text, in case that's the issue)?

In terms of running it, I compile first as x64, and call it as a .exe.

Script:

#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <Array.au3>
#include <WinAPI.au3>

Sleep(5000)

Local $window = "Batch Modes"
Local $controlIDHeader = "SysHeader321"
Local $controlIDTable = "WindowsForms10.SysListView32.app.0.141b42a_r9_ad11"

;Focus on the correct window in the application
Local $queueWindow = WinWait($window,"", 2)

;Go to the header in the queue Window (check if it is accessible)
Local $found = ControlFocus($queueWindow,"",$controlIDHeader)
;
If $found = 0 Then
    ConsoleWrite("FAIL: unable to locate header" & @LF)
Else
    ConsoleWrite("PASS: header located" & @LF)
EndIf

;Go to the table in the queue Window (check if it is accessible)
$found = ControlFocus($queueWindow,"",$controlIDTable)
;Pass IFF we reached queues window successfully
If $found = 0 Then
    ConsoleWrite("FAIL: unable to locate table" & @LF)
Else
    ConsoleWrite("PASS: table located" & @LF)
EndIf

;Q1 - Does GUISwitch do anything that control focus doesn't do? I don't see a difference when I omit the next line. It seems redundant.
Local $windowHandle = GUISwitch ($window)
ConsoleWrite("windowHandle: "&$windowHandle & @LF)

ConsoleWrite("Attempting to interact with table:" & @LF)

;Attempts to read the table data
Local $GUICtrlRead = GUICtrlRead($controlIDTable)
ConsoleWrite("GUICtrlRead: "& $GUICtrlRead & @LF)

Local $convertToString = String($GUICtrlRead)
ConsoleWrite("GUICtrlRead to String: "& $convertToString & @LF)

Local $GUICtrlReadExtended = GUICtrlRead($controlIDTable, $GUI_READ_EXTENDED)
ConsoleWrite("GUICtrlRead Extended: "& $GUICtrlReadExtended & @LF)

Local $ControlGetText = ControlGetText($window ,"",$controlIDTable)
ConsoleWrite("ControlGetText: "& $ControlGetText & @LF)

Local $ControlListViewGetItemCount = ControlListView($window ,"",$controlIDTable,"GetItemCount")
ConsoleWrite("CLV GetItemCount: "& $ControlListViewGetItemCount & @LF)

Local $ControlListViewGetSubItemCount = ControlListView($window ,"",$controlIDTable,"GetSubItemCount")
ConsoleWrite("CLV GetSubItemCount: "& $ControlListViewGetSubItemCount & @LF)

Local $ControlListViewGetSubItemText = ControlListView($window ,"",$controlIDTable,"GetText",1,1)
ConsoleWrite("CLV GetText (subitem 1, 1): "& $ControlListViewGetSubItemText & @LF)

Local $ControlListViewGetItemText = ControlListView($window ,"",$controlIDTable,"GetText", 1)
ConsoleWrite("CLV GetText (item 1): "&$ControlListViewGetItemText & @LF)

;Search term is in first column. It is unclear to me whether item numbers are 0-indexed or 1-indexed, so I tried both.
Local $rowSearch0 = ControlListView($window ,"",$controlIDTable,"FindItem","2578320",0)
ConsoleWrite("CLV FindItem 0: "&$rowSearch0 & @LF)
Local $rowSearch1 = ControlListView($window ,"",$controlIDTable,"FindItem","2578320",1)
ConsoleWrite("CLV FindItem 1: "&$rowSearch1 & @LF)

;Attempting to select a single row and extract text/data
Local $grab0 = ControlListView($window ,"",$controlIDTable,"Select", 0)
ConsoleWrite("CLV Select 0: "&$grab0 & @LF)
Local $selected0 = ControlListView($window ,"",$controlIDTable, "GetSelected")
ConsoleWrite("CLV GetSelected (of 0): "&$selected0 & @LF)
Local $text0 = ControlListView($window ,"",$controlIDTable, "GetText",$selected0)
ConsoleWrite("CLV GetText (of selected 0): "&$text0 & @LF)

Local $isSelected1 = ControlListView($window ,"",$controlIDTable,"GetSelectedCount")
ConsoleWrite("CLV GetSelectedCount, first try: "&$isSelected1 & @LF)

;Not sure if it is necessary to clear before a new selection
ControlListView($window ,"",$controlIDTable, "SelectClear")

Local $grab11 = ControlListView($window ,"",$controlIDTable,"Select", 1, 1)
ConsoleWrite("CLV Select 1, 1: "&$grab11 & @LF)
Local $selected11 = ControlListView($window ,"",$controlIDTable, "GetSelected")
ConsoleWrite("CLV GetSelected (of 1,1): "&$selected11 & @LF)
Local $text11 = ControlListView($window ,"",$controlIDTable, "GetText",$selected11)
ConsoleWrite("CLV GetText (of selected 1,1): "&$text11 & @LF)

Local $isSelected2 = ControlListView($window ,"",$controlIDTable,"GetSelectedCount")
ConsoleWrite("CLV GetSelectedCount, second try: "&$isSelected2 & @LF)

Output:

PASS :: header located
PASS :: table located
windowHandle: 0x0000000000000000
Attempting to interact with table:
GUICtrlRead: 0
GUICtrlRead to String: 0
GUICtrlRead Extended: 0
ControlGetText: 
CLV GetItemCount: 4
CLV GetSubItemCount: 11
CLV GetText (subitem 1, 1): 
CLV GetText (item 1): 0
CLV FindItem 0: 0
CLV FindItem 1: 0
CLV Select 0: 0
CLV GetSelected (of 0): 0
CLV GetText (of selected 0): 0
CLV GetSelectedCount, first try: 0
CLV Select 1, 1: 0
CLV GetSelected (of 1,1): 0
CLV GetText (of selected 1,1): 0
CLV GetSelectedCount, second try: 0
Ascend action complete :: OpenFirstInQueue

I'm looking into UDF functions in the meantime, but that's a more daunting task to search through them. Really curious if I should give up on ListView/GUI functions, or if there's a concept I'm missing.

Posted

I think Nine might have intended for me to start with _GUICtrlListView, but these seem to be a bust as well.

Snippet from new code:

;Trying GUI UDF
Local $UDFColumnCount = _GUICtrlListView_GetColumnCount ( $controlIDTable )
ConsoleWrite("$UDFColumnCount: "&$UDFColumnCount & @LF)

;https://www.autoitscript.com/forum/topic/167768-a-simple-function-to-print-an-array-in-console/
Func PrintList($List)
    If IsArray($List) Then
        Local $txt = ""
        For $i = 0 to UBound($List) -1
            $txt = $txt & "," & $List[$i]
        Next
        Local $out = StringMid($txt,2)
        Global $Result = "[" & $out & "]"
        ConsoleWrite($Result)
        Return $Result
    Else
        MsgBox(0, "List Error", "Variable is not an array or a list")
    EndIf
EndFunc

Local $GetItemTextArray = _GUICtrlListView_GetItemTextArray($controlIDTable, 1)
PrintList($GetItemTextArray)
ConsoleWrite(@LF)

Local $GetItemTextString = _GUICtrlListView_GetItemTextString ($controlIDTable, 1)
ConsoleWrite("$GetItemTextString: "&$GetItemTextString & @LF)

Output from this snippet:

$UDFColumnCount: 0
[0]
$GetItemTextString:

So with this set of functions, it's not even identifying the number of columns. I'm assuming I shouldn't use _GUICtrlListView_Create, since the table already exists in the application... is there any way to cast the control as a GUIListView before I attempt to interact with it?

---

Out of desperation, I tried interpreting this control as an Excel Table, Toolbar, etc. As expected, these didn't work.

Current full script/output below.

#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <Array.au3>
#include <WinAPI.au3>
#include <IE.au3>
#include <Word.au3>
#include <Array.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WinAPIConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>
#include <GuiToolbar.au3>

Sleep(5000)

Local $window = "Batch Modes"
Local $controlIDHeader = "SysHeader321"
Local $controlIDTable = "WindowsForms10.SysListView32.app.0.141b42a_r9_ad11"

;Focus on the correct window in the application
Local $queueWindow = WinWait($window,"", 2)

;Go to the header in the queue Window (check if it is accessible)
Local $found = ControlFocus($queueWindow,"",$controlIDHeader)
;
If $found = 0 Then
    ConsoleWrite("FAIL: unable to locate header" & @LF)
Else
    ConsoleWrite("PASS: header located" & @LF)
EndIf

;Go to the table in the queue Window (check if it is accessible)
$found = ControlFocus($queueWindow,"",$controlIDTable)
;Pass IFF we reached queues window successfully
If $found = 0 Then
    ConsoleWrite("FAIL: unable to locate table" & @LF)
Else
    ConsoleWrite("PASS: table located" & @LF)
EndIf

;Q1 - Does GUISwitch do anything that control focus doesn't do? I don't see a difference when I omit the next line. It seems redundant.
Local $windowHandle = GUISwitch ($window)
ConsoleWrite("windowHandle: "&$windowHandle & @LF)

ConsoleWrite("Attempting to interact with table:" & @LF)

;Attempts to read the table data
Local $GUICtrlRead = GUICtrlRead($controlIDTable)
ConsoleWrite("GUICtrlRead: "& $GUICtrlRead & @LF)

Local $convertToString = String($GUICtrlRead)
ConsoleWrite("GUICtrlRead to String: "& $convertToString & @LF)

Local $GUICtrlReadExtended = GUICtrlRead($controlIDTable, $GUI_READ_EXTENDED)
ConsoleWrite("GUICtrlRead Extended: "& $GUICtrlReadExtended & @LF)

Local $ControlGetText = ControlGetText($window ,"",$controlIDTable)
ConsoleWrite("ControlGetText: "& $ControlGetText & @LF)

Local $ControlListViewGetItemCount = ControlListView($window ,"",$controlIDTable,"GetItemCount")
ConsoleWrite("CLV GetItemCount: "& $ControlListViewGetItemCount & @LF)

Local $ControlListViewGetSubItemCount = ControlListView($window ,"",$controlIDTable,"GetSubItemCount")
ConsoleWrite("CLV GetSubItemCount: "& $ControlListViewGetSubItemCount & @LF)

Local $ControlListViewGetSubItemText = ControlListView($window ,"",$controlIDTable,"GetText",1,1)
ConsoleWrite("CLV GetText (subitem 1, 1): "& $ControlListViewGetSubItemText & @LF)

Local $ControlListViewGetItemText = ControlListView($window ,"",$controlIDTable,"GetText", 1)
ConsoleWrite("CLV GetText (item 1): "&$ControlListViewGetItemText & @LF)

;Search term is in first column. It's unclear to me whether item numbers are 0-indexed or 1-indexed, so I tried both.
Local $rowSearch0 = ControlListView($window ,"",$controlIDTable,"FindItem","2578320",0)
ConsoleWrite("CLV FindItem 0: "&$rowSearch0 & @LF)
Local $rowSearch1 = ControlListView($window ,"",$controlIDTable,"FindItem","2578320",1)
ConsoleWrite("CLV FindItem 1: "&$rowSearch1 & @LF)

;Attempting to select a single row and extract text/data
Local $grab0 = ControlListView($window ,"",$controlIDTable,"Select", 0)
ConsoleWrite("CLV Select 0: "&$grab0 & @LF)
Local $selected0 = ControlListView($window ,"",$controlIDTable, "GetSelected")
ConsoleWrite("CLV GetSelected (of 0): "&$selected0 & @LF)
Local $text0 = ControlListView($window ,"",$controlIDTable, "GetText",$selected0)
ConsoleWrite("CLV GetText (of selected 0): "&$text0 & @LF)

Local $isSelected1 = ControlListView($window ,"",$controlIDTable,"GetSelectedCount")
ConsoleWrite("CLV GetSelectedCount, first try: "&$isSelected1 & @LF)

;Not sure if it's necessary to clear before a new selection
ControlListView($window ,"",$controlIDTable, "SelectClear")

Local $grab11 = ControlListView($window ,"",$controlIDTable,"Select", 1, 1)
ConsoleWrite("CLV Select 1, 1: "&$grab11 & @LF)
Local $selected11 = ControlListView($window ,"",$controlIDTable, "GetSelected")
ConsoleWrite("CLV GetSelected (of 1,1): "&$selected11 & @LF)
Local $text11 = ControlListView($window ,"",$controlIDTable, "GetText",$selected11)
ConsoleWrite("CLV GetText (of selected 1,1): "&$text11 & @LF)

Local $isSelected2 = ControlListView($window ,"",$controlIDTable,"GetSelectedCount")
ConsoleWrite("CLV GetSelectedCount, second try: "&$isSelected2 & @LF)

;Trying GUI UDF
Local $UDFColumnCount = _GUICtrlListView_GetColumnCount ( $controlIDTable )
ConsoleWrite("$UDFColumnCount: "&$UDFColumnCount & @LF)

;https://www.autoitscript.com/forum/topic/167768-a-simple-function-to-print-an-array-in-console/
Func PrintList($List)
    If IsArray($List) Then
        Local $txt = ""
        For $i = 0 to UBound($List) -1
            $txt = $txt & "," & $List[$i]
        Next
        Local $out = StringMid($txt,2)
        Global $Result = "[" & $out & "]"
        ConsoleWrite($Result)
        Return $Result
    Else
        MsgBox(0, "List Error", "Variable is not an array or a list")
    EndIf
EndFunc

Local $GetItemTextArray = _GUICtrlListView_GetItemTextArray($controlIDTable, 1)
PrintList($GetItemTextArray)
ConsoleWrite(@LF)

Local $GetItemTextString = _GUICtrlListView_GetItemTextString ($controlIDTable, 1)
ConsoleWrite("$GetItemTextString: "&$GetItemTextString & @LF)

;These three sections, I uncommented one at a time to make sure I'm not seeing the error message from the previous attempt. All 3 produce an error.

;Trying IE UDF
;Local $IETable = _IETableWriteToArray($controlIDTable)
;PrintList($IETable)
;ConsoleWrite("$IETable @Error? " &@error)
;ConsoleWrite(@LF)

;Trying Word UDF
;Local $WordTable = _Word_DocTableRead($window, $controlIDTable)
;ConsoleWrite("$WordTable @Error? " &@error)
;ConsoleWrite(@LF)

;Trying to interpret as an array
;Local $ArrayView = _ArraySearch ( $controlIDTable, "099436")
;ConsoleWrite("$Array @Error? " &@error)
;ConsoleWrite(@LF)

;Trying the rebar control
Local $rebarAttempt = _GUICtrlRebar_GetRowCount($controlIDTable)
ConsoleWrite("$rebarAttempt rows: "&$rebarAttempt & @LF)

;Trying GUITab
Local $tabAttempt = _GUICtrlTab_GetRowCount($controlIDTable)
ConsoleWrite("$tabAttempt rows: "&$tabAttempt & @LF)

;Trying GUIToolbar
Local $toolbarAttempt = _GUICtrlToolbar_GetRows($controlIDTable)
ConsoleWrite("$toolbarAttempt rows: "&$toolbarAttempt & @LF)
PASS :: header located
PASS :: table located
windowHandle: 0x0000000000000000
Attempting to interact with table:
GUICtrlRead: 0
GUICtrlRead to String: 0
GUICtrlRead Extended: 0
ControlGetText: 
CLV GetItemCount: 862
CLV GetSubItemCount: 11
CLV GetText (subitem 1, 1): 
CLV GetText (item 1): 0
CLV FindItem 0: 0
CLV FindItem 1: 0
CLV Select 0: 0
CLV GetSelected (of 0): 0
CLV GetText (of selected 0): 0
CLV GetSelectedCount, first try: 0
CLV Select 1, 1: 0
CLV GetSelected (of 1,1): 0
CLV GetText (of selected 1,1): 0
CLV GetSelectedCount, second try: 0
$UDFColumnCount: 0
[0]
$GetItemTextString: 
$rebarAttempt rows: 0
$tabAttempt rows: 0
$toolbarAttempt rows: 0
Ascend action complete :: OpenFirstInQueue

 

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...