EricMessens Posted August 12, 2016 Share Posted August 12, 2016 Hi, I'm trying to write some code to get the items form a list in a form from another app. I tested with the following code. The only sensible data I get is from _GUICtrlListView_GetItemCount, _GUICtrlListView_GetColumnCount and _GUICtrlListView_GetColumn (except the header text returned is empty for all columns). How can I get the text from the items in the list with _GUICtrlListView_GetItemText ? What am I missing ? #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GuiListView.au3> Global $hLV,$iCount,$hControl,$sWinTitle,$aLVItems,$sText,$i,$aColumn,$j Func _WinWaitActivate($title,$text,$timeout=0) AutoItSetOption("WinTitleMatchMode",2) WinWait($title,$text,$timeout) If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc $sWinTitle="Object Explorer - xxxxxxxx" _WinWaitActivate($sWinTitle,"") $hLV=ControlgetHandle($sWinTitle,"","List1") $iCount=_GUICtrlListView_GetItemCount($hLV);number of items in List1 MsgBox(0,"LV items count",$iCount); result is number of rows in List1 MsgBox(0,"Find TREAT in list",_GUICtrlListView_FindText($hLV," ")) ;MsgBox(0,"LV",$iCount & " - " & _GUICtrlListView_GetColumnCount($hLV)); result is 5 if 1=2 Then MsgBox(0,"LV itemtext",$iCount & " - " & _GUICtrlListView_GetItemText($hLV,Number(0),Number(1))) MsgBox(0,"LV itemtext",$iCount & " - " & _GUICtrlListView_GetItemText($hLV,0,2)) MsgBox(0,"LV itemtext",$iCount & " - " & _GUICtrlListView_GetItemText($hLV,0,3)) MsgBox(0,"LV itemtext",$iCount & " - " & _GUICtrlListView_GetItemText($hLV,1,1)) MsgBox(0,"LV itemtext",$iCount & " - " & _GUICtrlListView_GetItemText($hLV,1,2)) MsgBox(0,"LV itemtext",$iCount & " - " & _GUICtrlListView_GetItemText($hLV,1,3)) MsgBox(0,"LV itemtext",$iCount & " - " & _GUICtrlListView_GetItemText($hLV,2,1)) MsgBox(0,"LV itemtext",$iCount & " - " & _GUICtrlListView_GetItemText($hLV,2,2)) MsgBox(0,"LV itemtext",$iCount & " - " & _GUICtrlListView_GetItemText($hLV,2,3)) MsgBox(0,"LV itemtext",$iCount & " - " & _GUICtrlListView_GetItemText($hLV,Number(0),Number(1))) MsgBox(0,"LV itemtext",$iCount & " - " & _GUICtrlListView_GetItemText($hLV,Number(0),Number(0))) MsgBox(0,"LV itemtext",$iCount & " - " & _GUICtrlListView_GetItemText($hLV,Number(1),Number(1))) MsgBox(0,"LV itemtext",$iCount & " - " & _GUICtrlListView_GetItemText($hLV,Number(1),Number(0))) MsgBox(0,"LV itemtext",$iCount & " - " & _GUICtrlListView_GetItemTextString($hLV,Number(2))); result is "||||" (there are 5 columns) ;MsgBox(0,"LV groupid",$iCount & " - " & _GUICtrlListView_GetItemGroupID($hLV,0)) $aLVItems=_GUICtrlListView_GetItemTextArray($hLV) For $i = 1 To $aLVItems[0] $sText &= StringFormat("Column[%2d] %s", $i, $aLVItems[$i]) & @CRLF Next MsgBox($MB_SYSTEMMODAL, "Information", "Items (All Columns) Text: " & @CRLF & @CRLF & $sText) for $j = 0 to 4 $aColumn=_GUICtrlListView_GetColumn($hLV,Number($j)) $sText="" For $i = 0 To 8 $sText &= StringFormat("%d %s", $i, $aColumn[$i]) & @CRLF Next MsgBox(0,"LV Colum header items",$sText) Next EndIf Link to comment Share on other sites More sharing options...
mikell Posted August 13, 2016 Share Posted August 13, 2016 You might remove this condition : "if 1=2 Then" and then try again Link to comment Share on other sites More sharing options...
EricMessens Posted September 1, 2016 Author Share Posted September 1, 2016 Sorry about that, I intended to exclude those lines from the test and should have used #cs and #ce. What I'm looking for is the code to read out the labels of items in a SysTreeView control eg. . get the labels of all the fields $hTreeView=ControlGetHandle("External Beam Planning","","[CLASS:SysTreeView32; INSTANCE:2]") ControlTreeView($hWnd,"",$hTreeView,"Expand","#0") ;this works ControlGetText("External Beam Planning","","[CLASS:SysTreeView32; INSTANCE:2]") doesn't work. I've devised the item's levels etc but I need to be able to get the labels of each item. code example : doesn't match the labels (from another record) $hLV=ControlGetHandle("External Beam Planning","","[CLASS:SysTreeView32; INSTANCE:2]") $items=_GUICtrlTreeView_GetCount($hLV);item count = 31 $h1=_GUICtrlTreeView_GetItemHandle($hLV,0);Plan ID, level=0,sibling count=1 $h2=_GUICtrlTreeView_GetFirstChild($hLV,$h1);CT ID, level=1, sibling count=4 $h3=_GUICtrlTreeView_GetNext($hLV,$h2);Registered Images, level=2, sibling count=3 $h4=_GUICtrlTreeView_GetNext($hLV,$h3);CBCT_1, level=3, sibling count=1 $h5=_GUICtrlTreeView_GetNext($hLV,$h4);Online:... , level=4, sibling count=2 $h6=_GUICtrlTreeView_GetNext($hLV,$h5);CBCT_1, level=4, sibling count=2 $h7=_GUICtrlTreeView_GetNext($hLV,$h6);AcqIsocenter, level=5, sibling count=3 $h8=_GUICtrlTreeView_GetNext($hLV,$h7);InitLaserIso, level=5, sibling count=3 $h9=_GUICtrlTreeView_GetNext($hLV,$h8);InitMatchIso, level=5, sibling count=3 $h10=_GUICtrlTreeView_GetNext($hLV,$h9);CT_1, level=2, sibling count=3 $h11=_GUICtrlTreeView_GetNext($hLV,$h10);CT_1, level=3, sibling count=9 _GUICtrlTreeView_GetTree($hLV,$h9) doesn't give me the text. Please, any hint to get these labels ? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now