Jump to content

FileSelectDrive and DirCopy


Recommended Posts

HI,

you can StringLeft the folder choice.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi,

You can use a root directory:

FileSelectFolder("Choose a folder.", "c:\")

Or what do you mean by «select just a drive»?

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

I think i understand what you need...

You probably will have to build your own Gui with File Select folder.. you just use DriveGetDrive, and make an TreeView elements.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

#include <GUIListBox.au3>

Opt('MustDeclareVars', 1)

Global $hListBox

Example_Internal()

Func Example_Internal()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("(Internal) List Box Dir", 400, 296)
    $hListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState()

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    ; Add files
    _GUICtrlListBox_BeginUpdate ($hListBox)
;~  _GUICtrlListBox_Dir ($hListBox, "", $DDL_DRIVES)
    _GUICtrlListBox_Dir ($hListBox, "", $DDL_DRIVES, False)
    _GUICtrlListBox_EndUpdate ($hListBox)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example_Internal

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox
    If Not IsHWnd($hListBox) Then $hWndListBox = GUICtrlGetHandle($hListBox)
    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
    $iCode = BitShift($iwParam, 16) ; Hi Word

    Switch $hWndFrom
        Case $hListBox, $hWndListBox
            Switch $iCode
                Case $LBN_SELCHANGE ; Sent when the selection in a list box has changed
                    _DebugPrint("$LBN_SELCHANGE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode & @LF & _
                            "-->Value:" & @TAB & GUICtrlRead($hListBox))
                    ; no return value
            EndSwitch
    EndSwitch
    ; Proceed the default Autoit3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default Autoit3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func _DebugPrint($s_text)
    $s_text = StringReplace($s_text, @LF, @LF & "-->")
    ConsoleWrite("!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF)
EndFunc   ;==>_DebugPrint

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

ok i got this

#include <GUIConstants.au3>
#include <Constants.au3>

$mainWindow = GUICreate("Select Drive", 200, 100)
$drives = DriveGetDrive("ALL")

If NOT @error Then
    $ctrl = GUICtrlCreateTreeView(3, 3, 194, 94)
    For $i = 1 to $drives[0]
        $treeItems = GUICtrlCreateTreeViewItem($drives[$i], $ctrl)
    Next
EndIf

GUISetState(@SW_SHOW, $mainWindow)

While 1
    $gMsg = GUIGetMsg()
    Switch $gMsg
    Case $GUI_EVENT_CLOSE
        Exit
    EndSwitch
WEnd

Now how do i get which is selected. i cant exactly change the variable each TreeviewItem uses can i? an array didnt work.

Link to comment
Share on other sites

Hi, On Event mode maybe?

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

$Gui = GUICreate("", 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "Event")
$TreeViev = GUICtrlCreateTreeView(3, 3, 94, 94)
_GetDrives()
GUISetState(@SW_SHOW, $Gui)

While 1
    Sleep(100)
Wend

Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            If GUICtrlRead(@GUI_CtrlId, 1) <> "No Drives Available" Then
                MsgBox(64,'Drive Selected.', "You've Selected Drive: " & GUICtrlRead(@GUI_CtrlId, 1))
            Else
                MsgBox(64,'No Drives Available.', "No Drives Available To Select.")
            EndIf
    EndSwitch
EndFunc

Func _GetDrives()
    Local $DGD = DriveGetDrive("ALL")
    If @error Then
        GUICtrlCreateTreeViewItem("No Drives Available", $TreeViev)
        GUICtrlSetOnEvent(-1, "Event")
        GUICtrlSetImage($TreeViev, "shell32.dll", -54, 2)
        GUICtrlSetImage($TreeViev, "shell32.dll", -54, 4)
    Else
        For $d = 1 To $DGD[0]
            GUICtrlCreateTreeViewItem("(" & StringUpper($DGD[$d]) & ")", $TreeViev)
            GUICtrlSetOnEvent(-1, "Event")
            GUICtrlSetImage($TreeViev, "shell32.dll", -9, 2)
            GUICtrlSetImage($TreeViev, "shell32.dll", -9, 4)
        Next
    EndIf
EndFunc
Other ways would be using GUIRegisterMsg()

Cheers

Link to comment
Share on other sites

Or:

#include <GUIConstants.au3>

Dim $data

$mainWindow = GUICreate("Select Drive", 200, 100)
$drives = DriveGetDrive("ALL")

If NOT @error Then
    $SelectDrive = GUICtrlCreateCombo("", 50, 30, 100, 17, $CBS_DROPDOWNLIST)
    For $i = 1 to $drives[0]
        $data &= DriveGetType($drives[$i]) &" "& StringUpper($drives[$i]) & "|"
    Next
    ConsoleWrite($data)
    GUICtrlSetData(-1, StringTrimRight($data, 1), StringRegExpReplace($data, "\|.*", ""))
EndIf

GUISetState(@SW_SHOW, $mainWindow)

While 1
    $gMsg = GUIGetMsg()
    Switch $gMsg
    Case $GUI_EVENT_CLOSE
        Exit
    EndSwitch
WEnd

:)

Link to comment
Share on other sites

Your welcome

If you want the drive icons to suit the drives (in xp that is) try this mild addition

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

$Gui = GUICreate("", 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "Event")
$TreeViev = GUICtrlCreateTreeView(3, 3, 94, 94)
_GetDrives()
GUISetState(@SW_SHOW, $Gui)

While 1
    Sleep(100)
Wend

Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            If GUICtrlRead(@GUI_CtrlId, 1) <> "No Drives Available" Then
                MsgBox(64,'Drive Selected.', "You've Selected Drive: " & GUICtrlRead(@GUI_CtrlId, 1))
            Else
                MsgBox(64,'No Drives Available.', "No Drives Available To Select.")
            EndIf
    EndSwitch
EndFunc

Func _GetDrives()
    Local $DGD = DriveGetDrive("ALL")
    If @error Then
        GUICtrlCreateTreeViewItem("No Drives Available", $TreeViev)
        GUICtrlSetOnEvent(-1, "Event")
        GUICtrlSetImage($TreeViev, "shell32.dll", _GetIco(-1), 2)
        GUICtrlSetImage($TreeViev, "shell32.dll", _GetIco(-1), 4)
    Else
        For $d = 1 To $DGD[0]
            GUICtrlCreateTreeViewItem("(" & StringUpper($DGD[$d]) & ")", $TreeViev)
            GUICtrlSetOnEvent(-1, "Event")
            GUICtrlSetImage(-1, "shell32.dll", _GetIco($DGD[$d]), 2)
            GUICtrlSetImage(-1, "shell32.dll", _GetIco($DGD[$d]), 4)
        Next
    EndIf
EndFunc

Func _GetIco($Drv = -1)
    If $Drv = -1 Then Return -54
    $DR = StringRegExpReplace($Drv, "[()]", "",2)
    Local $DGT = DriveGetType($DR)
    If @error Or $DGT = "" Then Return -54
    Switch $DGT
        Case "Removable"
            If $DR = "A:" Or $DR = "B:" Then Return -7
            Return -8
        Case "Fixed"
            Return -9
        Case "Network"
            If DriveStatus($DR) = "INVALID" Then Return -11
            Return -10
        Case "CDROM"
            Return -12
        Case "RAMDisk"
            Return -13
        Case "Unknown"
            Return -54
    EndSwitch
EndFunc

Cheers

Link to comment
Share on other sites

If your using Autoit to do the directory copy then you could do a _FileListToArray() then step through the array , this way you can track it as the files are copying , other then that you could probably use the win api functions in some way to monitor the process, but I don't have an example of doing it via api.

Cheers

Link to comment
Share on other sites

i could get all the files but how could i track it. and it also seems i cant do anything else until the copy is done

Look back to somewhere around August or September and I think I posted some file/folder functions that use the Windows progress indicator.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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