Normonator Posted May 18, 2010 Posted May 18, 2010 I made a script backup program to backup my scripts folder from my flash drive to a folder on a desktop, etc. but i wanted to add a progress bar so you can see how far it is. but when i run this script the dircopy function pauses the script and doesn't set the progress until it's already done. If anybody has a solution to this problem it'd be a huge help Thanks heres my script: $dir = FileSelectFolder('Choose Your Backup Location:','') If @error = 1 Then MsgBox(48,"Backup",'Backup Canceled!') Exit Else AdlibRegister('_prog') ProgressOn('Script Backup','Working...') $conf=_copy () If $conf = 1 then MsgBox(48,"Backup",'Backup Complete!') Else MsgBox(48,"Backup",'Backup Failed!') EndIf ProgressOff() Exit EndIf While True WEnd Func _prog () $orig = DirGetSize(@ScriptDir & '\scripts')/1024^2 $new = DirGetSize($dir)/1024^2 $prog = $new / $orig *100 ProgressSet($prog) EndFunc Func _copy () Return DirCopy('\scripts',$dir,1) EndFunc [member='That Guy']~~Normonator~~
KaFu Posted May 18, 2010 Posted May 18, 2010 DirCopy() is a blocking function, it waits for the result to return. Search the examples forum for a FileListToArray() UDF and combine that with FileCopy(,8). OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
cln Posted May 19, 2010 Posted May 19, 2010 (edited) I made a script backup program to backup my scripts folder from my flash drive to a folder on a desktop, etc. but i wanted to add a progress bar so you can see how far it is. but when i run this script the dircopy function pauses the script and doesn't set the progress until it's already done. If anybody has a solution to this problem it'd be a huge help Thanks heres my script: My script: expandcollapse popup#include <File.au3> $dir = FileSelectFolder('Choose Your Backup Location:','') $pathlen = StringLen($dir) If @error = 1 Then MsgBox(48,"Backup",'Backup Canceled!') Exit Else AdlibRegister('_prog') ProgressOn('Script Backup','Working...') $conf=_copy ($dir) If $conf = 1 then MsgBox(48,"Backup",'Backup Complete!') Else MsgBox(48,"Backup",'Backup Failed!') EndIf ProgressOff() Exit EndIf While True WEnd Func _prog () $orig = DirGetSize(@ScriptDir & '\scripts')/1024^2 $new = DirGetSize($dir)/1024^2 $prog = $new / $orig *100 ProgressSet($prog) EndFunc Func _copy($_Path) $folder = _FileListToArray($_Path, "*", 0) If Not IsArray($folder) Then Return 0 For $o = 1 To $folder[0] _copy($_Path & "\" & $folder[$o]) FileCopy ($_Path, @ScriptDir & '\scripts\'&StringTrimLeft($_Path,$pathlen)&"\",9) Next Return 1 EndFunc Edited May 19, 2010 by cln
Normonator Posted May 20, 2010 Author Posted May 20, 2010 Wow thanks for the help. So now that that works could any of you tell me how i can set a restore function to fade transparency in? [member='That Guy']~~Normonator~~
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