christiancdj Posted February 15, 2011 Share Posted February 15, 2011 how can i run the files in the list from the array? i got a list of files to install, but i dont get all files i always get the last dropped file to the array - what goes wrong? how can i install all droped files to the list? expandcollapse popup#include <GUIListBox.au3> #include <GuiConstantsEx.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <String.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListBoxConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Include <GuiListView.au3> #Include <File.au3> #include <Array.au3> #include <file.au3> Global $gaDropFiles[1], $iDropItem = -1 Global $WM_DROPFILES = 0x233 Global $hFile GUICreate(" My GUI acceptfile", 620, 320, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES $file = GUICtrlCreateButton("Install", 10, 5, 300, 40) $mylist = GUICtrlCreateList("", 10, 54, 441, 253, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL)) GUICtrlSetState($mylist, $GUI_DROPACCEPTED) GUISetState() GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES_FUNC') Global $Array While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_DROPPED Dim $sPath = _ArrayToString($gaDropFiles, "") GUICtrlSetData($mylist,$sPath) Case $file daisyChainRun() EndSwitch WEnd Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam) Local $nSize, $pFileName Local $nAmt = DllCall('shell32.dll', 'int', 'DragQueryFileW', 'hwnd', $wParam, 'int', 0xFFFFFFFF, 'ptr', 0, 'int', 255) For $i = 0 To $nAmt[0] - 1 $nSize = DllCall('shell32.dll', 'int', 'DragQueryFileW', 'hwnd', $wParam, 'int', $i, 'ptr', 0, 'int', 0) $nSize = $nSize[0] + 1 $pFileName = DllStructCreate('wchar[' & $nSize & ']') DllCall('shell32.dll', 'int', 'DragQueryFileW', 'hwnd', $wParam, 'int', $i, 'ptr', DllStructGetPtr($pFileName), 'int', $nSize) ReDim $gaDropFiles[$i + 1] $gaDropFiles[$i] = DllStructGetData($pFileName, 1) $pFileName = 0 Next EndFunc ;==>WM_DROPFILES_FUNC func daisyChainRun(); will be used to run selected scripts after they are properly sorted etc For $i = 1 To $gaDropFiles[0] RunWait(@ComSpec & " /c " & $gaDropFiles[$i] & " >> log.txt") Next EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 15, 2011 Moderators Share Posted February 15, 2011 christiancdj, It is much easier to let AutoIt do the hard work for you - like this: expandcollapse popup#include <GUIListBox.au3> #include <GuiConstantsEx.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <String.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListBoxConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <File.au3> #include <Array.au3> #include <file.au3> Global $gaDropFiles[1] = [0] GUICreate(" My GUI acceptfile", 620, 320, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES $file = GUICtrlCreateButton("Install", 10, 5, 300, 40) $mylist = GUICtrlCreateList("", 10, 54, 441, 253, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL)) GUICtrlSetState($mylist, $GUI_DROPACCEPTED) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_DROPPED ; Add file to list GUICtrlSetData($mylist, @GUI_DragFile) ; No need for the handler - AutoIt gets the path & name for you <<<<<<<<<< ; Add file to array $gaDropFiles[0] += 1 ReDim $gaDropFiles[$gaDropFiles[0] + 1] $gaDropFiles[$gaDropFiles[0]] = @GUI_DragFile Case $file daisyChainRun() EndSwitch WEnd Func daisyChainRun(); will be used to run selected scripts after they are properly sorted etc For $i = 1 To $gaDropFiles[0] ;RunWait(@ComSpec & " /c " & $gaDropFiles[$i] & " >> log.txt") ConsoleWrite(@ComSpec & " /c " & $gaDropFiles[$i] & " >> log.txt" & @CRLF) Next EndFunc ;==>daisyChainRun 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...
christiancdj Posted February 15, 2011 Author Share Posted February 15, 2011 wow thanks a lot, didn't know the funktion but now i got a new problem_ im realy confused - how can i move the files order up and down or even throw one out of the list? i realy dont know how @GUI_DragFile works, sorry Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 15, 2011 Moderators Share Posted February 15, 2011 i realy dont know how @GUI_DragFile worksIt has nothing to do with @GUI_DragFile - that just gets the filename into the list and array. What you need to do is manipulate the array and then redraw the list. I have added 3 buttons. The "Up" and "Delete" buttons work - I leave it to you to write the code for the "Down" button (Hint: look at the "Up" code). expandcollapse popup#include <GUIListBox.au3> #include <GuiConstantsEx.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <String.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListBoxConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <File.au3> #include <Array.au3> #include <file.au3> Global $gaDropFiles[1] = [0] GUICreate(" My GUI acceptfile", 620, 320, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES $file = GUICtrlCreateButton("Install", 10, 5, 300, 40) $mylist = GUICtrlCreateList("", 10, 54, 441, 253, BitOR($WS_BORDER, $WS_VSCROLL, $LBS_EXTENDEDSEL)) GUICtrlSetState($mylist, $GUI_DROPACCEPTED) $hUp_Button = GUICtrlCreateButton("Up", 470, 54, 80, 30) $hDown_Button = GUICtrlCreateButton("Down", 470, 277, 80, 30) $hDel_Button = GUICtrlCreateButton("Delete", 470, 165, 80, 30) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_DROPPED ; Add file to list GUICtrlSetData($mylist, @GUI_DragFile) ; No need for the handler - AutoIt gets the path & name for you <<<<<<<<<< ; Add file to array $gaDropFiles[0] += 1 ReDim $gaDropFiles[$gaDropFiles[0] + 1] $gaDropFiles[$gaDropFiles[0]] = @GUI_DragFile Case $file daisyChainRun() Case $hUp_Button $aIndex = _GUICtrlListBox_GetSelItems($mylist) If $aIndex[0] = 1 Then ; Check if aleady at top If $aIndex[1] <> 0 Then ; Swap elements _ArraySwap($gaDropFiles[$aIndex[1]], $gaDropFiles[$aIndex[1] + 1]) ; Destroy list GUICtrlSetData($mylist, "") ; Rewrite list For $i = 1 To $gaDropFiles[0] GUICtrlSetData($mylist, $gaDropFiles[$i]) Next EndIf EndIf Case $hDown_Button Case $hDel_Button $aIndex = _GUICtrlListBox_GetSelItems($mylist) If $aIndex[0] = 1 Then ; Remove form array and lower count _ArrayDelete($gaDropFiles, $aIndex[1] + 1) $gaDropFiles[0] -= 1 ; Destroy list GUICtrlSetData($mylist, "") ; Rewrite list For $i = 1 To $gaDropFiles[0] GUICtrlSetData($mylist, $gaDropFiles[$i]) Next EndIf EndSwitch WEnd Func daisyChainRun(); will be used to run selected scripts after they are properly sorted etc For $i = 1 To $gaDropFiles[0] ;RunWait(@ComSpec & " /c " & $gaDropFiles[$i] & " >> log.txt") ConsoleWrite(@ComSpec & " /c " & $gaDropFiles[$i] & " >> log.txt" & @CRLF) Next EndFunc ;==>daisyChainRun All clear? Please ask if not. 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...
christiancdj Posted February 15, 2011 Author Share Posted February 15, 2011 thanks your are a genius thanks a lot Link to comment Share on other sites More sharing options...
christiancdj Posted February 16, 2011 Author Share Posted February 16, 2011 (edited) i got no idea why its not working, please help cant move down objts $aIndex = _GUICtrlListBox_GetSelItems($mylist) If $aIndex[0] = 1 Then ;~ ; Check if aleady at top If $aIndex[1] <> 0 Then ;~ ; Swap elements _ArraySwap($gaDropFiles[$aIndex[1]+1], $gaDropFiles[$aIndex[1]]) _ArrayDisplay($mylist) ; Destroy list GUICtrlSetData($mylist, "") ; Rewrite list For $i = 1 To $gaDropFiles[0] GUICtrlSetData($mylist, $gaDropFiles[$i]) Next ;~ EndIf EndIf EndIf Edited February 16, 2011 by christiancdj Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 16, 2011 Moderators Share Posted February 16, 2011 christiancdj,You were supposed to base the code on the "Up" code, not copy it! You need to change 2 things to get it to work:- 1. You need to check if the item is at the bottom, not the top - look at the <<<<<<<<< 1 line- 2. Because the array is 1-based and the list is 0-based you need to adjust the elements to swap - look at the <<<<<<<<< 2 line$aIndex = _GUICtrlListBox_GetSelItems($mylist) If $aIndex[0] = 1 Then ; Check if aleady at bottom If $aIndex[1] <> $gaDropFiles[0] - 1 Then ; <<<<<<<<<<<<<<<<<<<< 1 ; Swap elements _ArraySwap($gaDropFiles[$aIndex[1] + 1], $gaDropFiles[$aIndex[1] + 2]) ; <<<<<<<<<<<<<<<<<<<< 2 ; Destroy list GUICtrlSetData($mylist, "") ; Rewrite list For $i = 1 To $gaDropFiles[0] GUICtrlSetData($mylist, $gaDropFiles[$i]) Next EndIf EndIfDo you understand the 0-based vs 1-based point? Ask if not, it is quite important when you deal with arrays and indices. 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...
christiancdj Posted February 16, 2011 Author Share Posted February 16, 2011 got nothing to say you are a god thanks again it got it now 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