ileandros Posted February 22, 2012 Share Posted February 22, 2012 Hello, I made a simple progg with a menu and a listbox. One of the menu item is $file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)") which open the window to chose a file and then the listbox read that item. I was wondering is it posible to make a button or a menuitem to generate all the existing files in the computer or user and set the Data to the listbox??? Thanks I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 22, 2012 Moderators Share Posted February 22, 2012 ileandros,The RecFileListToArray UDF in my sig will list all files within a given path -you can set filters to limit the type if you wish. But beware - if you use it on a whole drive it can take a while to find them all and the resultant array is a fair size. 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...
ileandros Posted February 22, 2012 Author Share Posted February 22, 2012 Tha was usefull but i dont know why i got error. Cant read RecFileListToArray.I tried to include the #include "RecFileListToArray.au3" but didn't got somewhere. Doesnt accept it.I added #include <File.au3> and tried this one If $msg = $fileitem Then $file = _FileListToArray(@DesktopDir, "*") GUICtrlSetData($List1, $file) EndIf but didnt make it.... I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 22, 2012 Moderators Share Posted February 22, 2012 ileandros, Of course that will not work - both of those functions return arrays. So you will need to loop through the arrays to extract the filenames to fill your list. 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...
ileandros Posted February 22, 2012 Author Share Posted February 22, 2012 So i have to create it seperate and then set the listbox data to read the array??? I'm lost I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 22, 2012 Moderators Share Posted February 22, 2012 ileandros, Here is one way you might do it: #include <GUIConstantsEx.au3> #include <File.au3> ; Get the path of the AutoIt exe $sPath = StringReplace(@AutoItExe, "AutoIt3.exe", "") ; Read all the files on that path into an array $aFiles = _FileListToArray($sPath, "*.*", 1) ; Create a GUI $hGUI = GUICreate("Test", 500, 500) ; Create a list $cList = GUICtrlCreateList("", 10, 10, 200, 200) ; And fill it with our data For $i = 1 To $aFiles[0] GUICtrlSetData($cList, $aFiles[$i]) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd 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...
ileandros Posted February 22, 2012 Author Share Posted February 22, 2012 All clear besides 1 part.Att the $sPath = StringReplace(@AutoItExe, "AutoIt3.exe", "") why "Autoit.exe", "" ?What does the second and third part of parenthesis means. I read them but didnt realy understood. I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 22, 2012 Moderators Share Posted February 22, 2012 ileandros,That line was just to make sure I used a path which would exist on your machine and so you woudl have a running example. @AutoItExe returns the path and name of the AutoIt3.exe file - I used StringReplace to replace the "\AutoIt.exe" witha a simple "\" so that we got the path without the name. There are many ways of doing this - I chose that one. As to the exact meaning of the parameters - go and read the Help file for StringReplace. 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...
ileandros Posted February 22, 2012 Author Share Posted February 22, 2012 (edited) I already read the helpfile but didn't understand sth :/ All clear until now. One more question. I was checking for paths @path and i only found paths like @DesktopDir, @TimpDir etc... Is there a path that read the entire user or computer?? And if i try (@DesktopDir & @TempDir...) I get error :/ Edited February 22, 2012 by ileandros I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 22, 2012 Moderators Share Posted February 22, 2012 ileandros,There are no macros for "the whole thing" What you can do is to use DriveGetDrive to list the available drives and then search each of them in turn by looping through the array and using the root (e.g. C:) as the path to search. 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...
ileandros Posted February 22, 2012 Author Share Posted February 22, 2012 Ohhh god. It reads everything but i got a damn error msg. It cant execute most off them. Here is the script. expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <File.au3> Example() Func Example() Local $szDrive, $szDir, $szFName, $szExt, $path, $guimax Local $filemenu, $fileitem, $read Local $helpmenu, $infoitem, $exititem, $recentfilesmenu Local $viewmenu, $viewstatusitem, $cancelbutton Local $statuslabel, $msg, $file, $gui $guicreate = GUICreate("My GUI menu", 300, 200) $List1 = GUICtrlCreateList("", 0,0,299, 150) GUICtrlSetData(-1, "") $filemenu = GUICtrlCreateMenu("&File") $fileitem = GUICtrlCreateMenuItem("Open", $filemenu) GUICtrlSetState(-1, $GUI_DEFBUTTON) $helpmenu = GUICtrlCreateMenu("?") GUICtrlCreateMenuItem("Save", $filemenu) GUICtrlSetState(-1, $GUI_DISABLE) $clearbutton = GUICtrlCreateButton("Clear", 115, 150, 70, 20) GUICtrlSetState($clearbutton, $GUI_DISABLE) $infoitem = GUICtrlCreateMenuItem("Info", $helpmenu) $exititem = GUICtrlCreateMenuItem("Exit", $filemenu) GUICtrlCreateMenuItem("", $filemenu, 2) ; create a separator line $viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu) GUICtrlSetState(-1, $GUI_CHECKED) $executebutton = GUICtrlCreateButton("Execute", 10, 150, 70, 20) GUICtrlSetState(-1, $GUI_FOCUS) $cancelbutton = GUICtrlCreateButton("Exit", 220, 150, 70, 20) $sPath = StringReplace(@DesktopDir, "AutoIt3.exe", "") $aFiles = _FileListToArray($sPath, "*.*", 1) For $i = 1 To $aFiles[0] GUICtrlSetData($List1, $aFiles[$i]) Next GUISetState() While 1 $msg = GUIGetMsg() If $msg = $fileitem Then $file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)") If @error <> 1 Then $FILE = StringMid($FILE,StringInStr($FILE,"",2,-1) +1) GUICtrlSetData($List1, $file) GUICtrlSetState($clearbutton, $GUI_ENABLE) EndIf EndIf Switch $msg Case $executebutton $read = GUICtrlRead($List1) if $read = true Then ShellExecute($read) EndIf case $clearbutton if $fileitem = true Then GUICtrlSetData($List1, "") GUICtrlSetState($clearbutton, $GUI_DISABLE) EndIf EndSwitch If $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton Or $msg = $exititem Then ExitLoop If $msg = $infoitem Then MsgBox(0, "Info", "Only a test...") WEnd GUIDelete() EndFunc ;==>Example I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
BrewManNH Posted February 22, 2012 Share Posted February 22, 2012 You're searching for all file types, most of which aren't executable or have default programs to open them. What exactly are you trying to do with this script? If you're looking for all executable files to list, even that doesn't make a whole lot of sense because there are some that can't be started normally, they'd need to be started by other processes or with parameters to even work at all. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
ileandros Posted February 22, 2012 Author Share Posted February 22, 2012 Yeah its true that some file are not executable but it doesnt even execute that can b e executed. If i add the same item with menuitem (Open) then it executes it. Can i make its load only executable items??? I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
kylomas Posted February 22, 2012 Share Posted February 22, 2012 ileandros, What error are you getting? I can execute every object listed without problems... kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
ileandros Posted February 22, 2012 Author Share Posted February 22, 2012 Error = MsgBox cup (Windows can not find ' '. Make sure you typed the name correctly, and then try again.) I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
kylomas Posted February 22, 2012 Share Posted February 22, 2012 ileandros, Your problem seems to be as BrewmanH suggests, you are not getting fully qualified executable objects (show a screen shot of what you are getting). IT is working for me because the path is resolving to my desktop which has only clickable links on it... kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
BrewManNH Posted February 22, 2012 Share Posted February 22, 2012 Try changing your ShellExecute line to this: ShellExecute($sPath & "" & $read) Your program names don't have a path, so there is no way for Windows to find them. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
ileandros Posted February 22, 2012 Author Share Posted February 22, 2012 That did it BrewManNH!!! But why couldn't i execute them when they were auto loaded by the progg since i could execute them if i added the same item with the menuitem(Open)??? Isn't that weird??? I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
BrewManNH Posted February 22, 2012 Share Posted February 22, 2012 Maybe the items you manually added were located in the Windows path environment variable, I'd have no way of knowing because I don't know what it is you did. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
ileandros Posted February 22, 2012 Author Share Posted February 22, 2012 No the path is @DesktopDir and i loaded the same item that was automaticly loaded. :/ I even check the path of the item and it was the same. I don't know. You said above that im searching all types of files and most of them are not executable. Is there a way to make it load only executable files?? I feel nothing.It feels great. 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