Jump to content
Sign in to follow this  
ileandros

How to read items??

Recommended Posts

ileandros

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.

Share this post


Link to post
Share on other sites
Melba23

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
ileandros

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.

Share this post


Link to post
Share on other sites
Melba23

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
ileandros

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.

Share this post


Link to post
Share on other sites
Melba23

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
ileandros

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.

Share this post


Link to post
Share on other sites
Melba23

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
ileandros

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 by ileandros

I feel nothing.It feels great.

Share this post


Link to post
Share on other sites
Melba23

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
ileandros

Ohhh god.

It reads everything but i got a damn error msg. It cant execute most off them.

Here is the script.

#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.

Share this post


Link to post
Share on other sites
BrewManNH

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 Gude
How 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

Share this post


Link to post
Share on other sites
ileandros

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.

Share this post


Link to post
Share on other sites
kylomas

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

Share this post


Link to post
Share on other sites
ileandros

Error = MsgBox cup (Windows can not find ' '. Make sure you typed the name correctly, and then try again.)


I feel nothing.It feels great.

Share this post


Link to post
Share on other sites
kylomas

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

Share this post


Link to post
Share on other sites
BrewManNH

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 Gude
How 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

Share this post


Link to post
Share on other sites
ileandros

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.

Share this post


Link to post
Share on other sites
BrewManNH

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 Gude
How 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

Share this post


Link to post
Share on other sites
ileandros

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×