kevinz Posted January 6, 2015 Share Posted January 6, 2015 I'm trying to display a list of files that are located within a directory. This is the relevant code that I have so far: expandcollapse popup; Includes the GuiConstants (required for GUI function usage) #include <GuiConstants.au3> #include <File.au3> #include <Array.au3> Global $inputBox, $downloadsURL, $files ; Change to OnEvent mode Opt('GUIOnEventMode', 1) ; GUI Creation GuiCreate("Downloads Script", 400, 200) ; Runs the GUIExit() function if the GUI is closed GUISetOnEvent($GUI_EVENT_CLOSE, 'GUIExit') ; Button1 GUICtrlCreateButton("Download File", -1, 60) GUICtrlSetOnEvent(-1, 'runDownload') ; Runs function when pressed Func runDownload() $files = _FileListToArray("C:\Users\<user.name>\Pictures" , "*." , 1) _ArrayDisplay($files) EndFunc ; Shows the GUI after the function completes GUISetState(@SW_SHOW) ; Idles the script in an infinite loop - this MUST be included when using OnEvent mode While 1 Sleep(500) WEnd ; This function makes the script exit when the GUI is closed Func GUIExit() Exit EndFunc After clicking the button, nothing happens. the script just runs forever.... What am I missing?? On a side note... long term goal for this script is for it to execute whatever file is located within that particular directory... Would it be possible for me to pass an array value into the "Run" or "ShellExecute" functions? Also, I know that the "user.name" could cause issues, but I only changed it in the code above for privacy purposes... Thanks for any help you may be able to provide... it is appreciated! Link to comment Share on other sites More sharing options...
JohnOne Posted January 6, 2015 Share Posted January 6, 2015 (edited) It's because $files is not an array. Check your path and filter. Edited January 6, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted January 6, 2015 Share Posted January 6, 2015 Check the parameters of the functions you mentioned and see if the take arrays. Loop through the array instead. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 6, 2015 Moderators Share Posted January 6, 2015 expandcollapse popup; Includes the GuiConstants (required for GUI function usage) #include <GuiConstants.au3> #include <File.au3> #include <Array.au3> Global $inputBox, $downloadsURL, $files ; Change to OnEvent mode Opt('GUIOnEventMode', 1) ; GUI Creation GUICreate("Downloads Script", 400, 200) ; Runs the GUIExit() function if the GUI is closed GUISetOnEvent($GUI_EVENT_CLOSE, 'GUIExit') ; Button1 GUICtrlCreateButton("Download File", 0, 60) GUICtrlSetOnEvent(-1, 'runDownload') ; Runs function when pressed ; Shows the GUI after the function completes GUISetState(@SW_SHOW) ; Idles the script in an infinite loop - this MUST be included when using OnEvent mode While 1 Sleep(500) WEnd Func runDownload() $files = _FileListToArray(@UserProfileDir & "\Pictures", "*.*", 1) _ArrayDisplay($files) EndFunc ;==>runDownload ; This function makes the script exit when the GUI is closed Func GUIExit() Exit EndFunc ;==>GUIExit Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
kevinz Posted January 7, 2015 Author Share Posted January 7, 2015 Check the parameters of the functions you mentioned and see if the take arrays. Loop through the array instead. So I was able to get the list of files to populate into the array. However I was not able to get the file from the array to execute. I tried ShellExecute($files[0]) and that didn't work.. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 7, 2015 Moderators Share Posted January 7, 2015 (edited) [0] is the number of indexes in the array. For $i = 1 To UBound($files) - 1 ShellExecute($files[$i]) Next Although, I'm unsure how you're going to manage opening a lot of "photos". Edited January 7, 2015 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
JohnOne Posted January 7, 2015 Share Posted January 7, 2015 Might have to also add folder path to shellexecute. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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