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