Jump to content

FileSelectFolder


Guest tilbste
 Share

Recommended Posts

Guest tilbste

I'd like to display the files and subfolders of a Win2000 folder:

"C:\Documents and Settings\" & @username & "\Local Settings\Temp"

FileSelectFolder looks good, but doesn't display files. Is there a similar function to do this?

Alternatively, I've tried using the Windows File Open fialog box, but I can't seem to close it.

Any ideas?

Thanks.

Link to comment
Share on other sites

Hi,

$message = "Hold down Ctrl or Shift to choose multiple files."

$var = FileOpenDialog($message, "C:\Windows\", "Images (*.jpg;*.bmp)", 1 + 4 )

If @error Then
    MsgBox(4096,"","No File(s) chosen")
Else
    $var = StringReplace($var, "|", @CRLF)
    MsgBox(4096,"","You chose " & $var)
EndIf

Andre

What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!
Link to comment
Share on other sites

Guest tilbste

Hi,

$message = "Hold down Ctrl or Shift to choose multiple files."

$var = FileOpenDialog($message, "C:\Windows\", "Images (*.jpg;*.bmp)", 1 + 4 )

If @error Then
    MsgBox(4096,"","No File(s) chosen")
Else
    $var = StringReplace($var, "|", @CRLF)
    MsgBox(4096,"","You chose " & $var)
EndIf

Andre

<{POST_SNAPBACK}>

This wasn't exactly what I was looking for. I was hoping to find out how to close the File Open dialog box. But never mind, I decided to use a Windows Explorer window instead. Here's the somewhat finished code (sorry it's not heavily documented, but is heavily borrowed from other posts in the forum ;-)

;==============================================================================================
;
; Program Name:  Delete Temp Files
; Description:    Simple GUI to list and delete files in 
;                   C:\documents and settings\<profile>\local settings\temp
;         
; Author(s):        <tilbste@statcan.ca>
;
;==============================================================================================

#include <GUIConstants.au3>

Opt("GUIOnEventMode",1)
GUICreate("Delete Temp Files", 350, 80)

WinSetOnTop("Delete Temp Files", "", 1)

Opt("GUICoordMode",2)
GUICtrlCreateLabel("Click to List or Delete files in:", 10, 10, 330)
GUICtrlCreateLabel("C:\Documents and Settings\" & @username & "\Local Settings\Temp", -1, 0)

$ListID  = GUICtrlCreateButton("List", -1, 0, 50, 20)
GUICtrlSetOnEvent($ListID,"OnList")

$DeleteID   = GUICtrlCreateButton("Delete", 0, -1, 50, 20)
GUICtrlSetOnEvent($DeleteID,"OnDelete")

$ExitID = GUICtrlCreateButton("Exit", 0, -1, 50, 20)
GUICtrlSetOnEvent($ExitID,"OnExit")

GUISetOnEvent($GUI_EVENT_CLOSE,"OnExit")
GUISetState() ; display the GUI

While 1
   Sleep (1000)
WEnd

;--------------- Functions ---------------
Func OnList()
    Run ( "explorer.exe C:\Documents and Settings\" & @username & "\Local Settings\Temp" , "")
;   FileOpenDialog("Temp Folder", "C:\Documents and Settings\" & @username & "\Local Settings\Temp", "All (*.*)", 1 + 4 )
EndFunc

Func OnDelete()

;this deletes everything in $dir

    $dir = "C:\Documents and settings\" & @Username & "\Local Settings\Temp\"

    $fHandle = FileFindFirstFile($dir & "*.*")
    If $fHandle >= 0 Then
        While 1
            $result = FileFindNextFile($fHandle)
            If @ERROR Then ExitLoop
            If $result <> "." And $result <> ".." Then
                If StringInStr(FileGetAttrib($dir & $result),"D") Then
                    DirRemove($dir & $result,1)
                Else
                    FileDelete($dir & $result)
                EndIf
            EndIf
        Wend
        FileClose($fHandle)
    EndIf

EndFunc

Func OnExit()
    If WinExists("C:\Documents and Settings\" & @username & "\Local Settings\Temp") Then 
        WinClose("C:\Documents and Settings\" & @username & "\Local Settings\Temp", "")
    EndIf
    Exit
EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...