Velnes Posted March 3, 2011 Share Posted March 3, 2011 $FileList = _FileListToArray(@DesktopDir) $avArray[0] = $FileList[0] $avArray[1] = $FileList[1] $avArray[2] = $FileList[2] $items[1] = GUICtrlCreateListViewItem($FileList[1], $tree) $items[2] = GUICtrlCreateListViewItem($FileList[2], $tree) GUICtrlSetData($items[0], $avArray[1]) GUICtrlSetData($items[0], $avArray[2]) thats wat i cant figure out... how do u make like just one $items[x] so that it repeats from that one tself to like 99 max and same for $avArray[x] im not good at this thing at all i just dont want script to be with 99 lines of $items[1] $items[2] so on ... maybe there is a way to make just one $avArray[x] which will be as all of avArrays from 1 to 99 ? i hope u get my question thnx for readin Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 3, 2011 Moderators Share Posted March 3, 2011 Velnes,You need to look at For...Next in the Help file. These 2 commands produce loops which allow you to repeat commands a certain number of times. In your example you would do something like this:$FileList = _FileListToArray(@DesktopDir) For $i = 1 To $FileList[0] ; Tell AutoIt to start at 1 and go up to the value of $FileList[0] $avArray[$i] = $FileList[$i] ; $i will increase each time you go round the loop $items[$i] = GUICtrlCreateListViewItem($FileList[$i], $tree) GUICtrlSetData($items[$i], $avArray[$i]) Next ; AutoIt automatically increases the value of $i here until it reaches the value of $FileList[0]All clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Velnes Posted March 3, 2011 Author Share Posted March 3, 2011 yes,al clear didnt know u can do for $i = 1 to $soemthing[number] didnt u can do like that well there is a first time for everything and everyone thnxalot u helped me very much Link to comment Share on other sites More sharing options...
Velnes Posted March 3, 2011 Author Share Posted March 3, 2011 ok anotehr problem..just got back from school and tryed solving this thig.. whith variables i cant get it to read the currently selected item text... Global $avArray[99], $items[99], $FileList[99] $FileList = _FileListToArray(@desktopdir) $tree = GUICtrlCreateListView("testtttt",0, 50, 250, 200) For $i = 1 To $FileList[0] ; Tell AutoIt to start at 1 and go up to the value of $FileList[0] $avArray[$i] = $FileList[$i] ; $i will increase each time you go round the loop $items[$i] = GUICtrlCreateListViewItem($FileList[$i], $tree) GUICtrlSetData($items[$i], $avArray[$i] & "|" & "test") Next ; AutoIt automatically increases the value of $i here until it reaches the value of $FileList[0] $test = GUICtrlCreateButton("run test", 5, 5, 100, 20) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $test MsgBox(0, "", GUICtrlRead($items[$i])) EndSwitch WEnd so when i press run test button it wont show me the text of the line selected in that treeview.. i get 0 all the time... thnx for help (handshake) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 3, 2011 Moderators Share Posted March 3, 2011 Velnes,As explained in the Help file you need to use GUICtrlRead on the ListView to get the ControlID if the selected item and then use GUICtrlRead again on that. Looks a bit cumbersome but it works:#include <GUIConstantsEx.au3> #include <File.au3> Global $avArray[99], $items[99], $FileList[99] $FileList = _FileListToArray(@DesktopDir) GUICreate("Test", 500, 500) $tree = GUICtrlCreateListView("testtttt", 0, 50, 250, 200) For $i = 1 To $FileList[0] $avArray[$i] = $FileList[$i] $items[$i] = GUICtrlCreateListViewItem($FileList[$i], $tree) GUICtrlSetData($items[$i], $avArray[$i] & "|" & "test") Next $test = GUICtrlCreateButton("run test", 5, 5, 100, 20) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $test MsgBox(0, "", GUICtrlRead(GUICtrlRead($tree))) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndSwitch WEndAll clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Velnes Posted March 3, 2011 Author Share Posted March 3, 2011 haha lol i was trying the double guictrlread thing but didnt work for me.. coz i did with $items[$i] :DDDD lol wata failer i am... but hmm when the text is there in msgbox it also adds that ' | ' character at end.. how to remove that i dont actualy see anything in code wat could cause this to appear lol sorry for my stupidity but this thing is my worst nightmare since i never used treeview Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 3, 2011 Moderators Share Posted March 3, 2011 Velnes,i never used treeviewAnd you are not using one now - you are using a ListView whcih is a very different beast. You get the "|" because the return value splits the columns using that character. I know you only have 1 column, but it still appears. Just use StringTrimRight to get rid of it. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Velnes Posted March 3, 2011 Author Share Posted March 3, 2011 aww ok thnx very much ! luv u :} Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 3, 2011 Moderators Share Posted March 3, 2011 Velnes,luv u :}Merely platonic I trust! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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