Sign in to follow this  
Followers 0
emendelson

Zip.au3 _zip_unzipall: automatically confirm folder overwrite?

10 posts in this topic

#1 ·  Posted (edited)

Zip.au3 is a superb add-on which I'm using very successfully. I have one question to which I can't figure out an answer. Part of my script looks like this:

$mydir = @ProgramFilesDir + "MyFolder"
$gszip = @TempDir & "gslite.zip"
_Zip_UnzipAll($gszip, $mydir & "", 0)

The first time my script runs, of course, it writes the contents of gslite.zip into $mydir. The second time a user runs the script, Windows pops up a "Confirm Folder Replace" dialog box saying that the target directory and files already exist; should I replace them, Yes, Yes to All, No?

I can't figure out how automate the user's response to that dialog. (I want the script to answer "Yes to All"). I can't place WinWait and then Send AFTER the _Zip_UnzipAll line, because the window I am waiting for will already have been dismissed by the time the _Zip_UnzipAll function is complete. I can't put WinWait and Send BEFORE that _Zip_UnzipAll line, because the "Confirm Folder Replace" dialog won't appear until after the _Zip_UnzipAll line is reached.

Is it possible to copy the _Zip_UnzipAll function into my main script, and add the lines WinWait, Send, etc., to the function itself? If so, how might I do that?

The _Zip_UnzipAll function looks like this:

;===============================================================================
;
; Function Name:    _Zip_UnzipAll()
; Description:    Extract all files contained in a ZIP Archieve.
; Parameter(s):  $hZipFile - Complete path to zip file that will be created (or handle if existant)
;    $hDestPath - Complete path to where the files will be extracted
;    $flag = 1
;    - 1 no progress box
;    - 0 progress box
; Requirement(s):   none.
; Return Value(s):  On Success - 0
;                  On Failure - sets @error 1~3
;    @error = 1 no Zip file
;    @error = 2 no dll
;    @error = 3 dll isn't registered
; Author(s):        torels_
; Notes:   The return values will be given once the extracting process is ultimated... it takes some time with big files
;
;===============================================================================
Func _Zip_UnzipAll($hZipFile, $hDestPath, $flag = 1)
Local $DLLChk = _Zip_DllChk()
If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll
If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path
If Not FileExists($hZipFile) Then Return SetError(2, 0, 0) ;no zip file
If Not FileExists($hDestPath) Then DirCreate($hDestPath)
Local $aArray[1]
$oApp = ObjCreate("Shell.Application")
$oApp.Namespace($hDestPath).CopyHere($oApp.Namespace($hZipFile).Items)
For $item In $oApp.Namespace($hZipFile).Items
  _ArrayAdd($aArray, $item)
Next
While 1
  If $flag = 1 then _Hide()
  If FileExists($hDestPath & "" & $aArray[UBound($aArray) - 1]) Then
   Return SetError(0, 0, 1)
   ExitLoop
  EndIf
  Sleep(500)
WEnd
EndFunc   ;==>_Zip_UnzipAll

Thanks for any help with this.

Edited by emendelson

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Thanks for any help with this.

Test post

Edit: oh, wow, I'm not banned anymore, great.

Any way, I didn't read your entire post, so I am assuming you need to just make sure certain files do not exist before extracting data from a zip file right?

Just create a function that makes sure those files do not exist before extracting any data.

Edited by THAT1ANONYMOUSEDUDE

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

Edit: oh, wow, I'm not banned anymore, great.

Your choice whether it remain like this and I removed the obnoxious signature IP thing.

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Your choice whether it remain like this and I removed the obnoxious signature IP thing.

If you want me to remove it, I will.

Edit: I see you already did it.. I do not have a problem with you or melba, whatever my views, I am sorry if they conflict with yours, I am not here to change your views or opinions on anything, I will not bring anything even remotely related to what I had before, you have my word and my apologies, especially to melba.

Edited by THAT1ANONYMOUSEDUDE

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

THAT1ANONYMOUSEDUDE,

my apologies, especially to melba

Accepted. :)

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

Any way, I didn't read your entire post, so I am assuming you need to just make sure certain files do not exist before extracting data from a zip file right?

Sorry - I should have been more clear. No - I want the program to click "Yes to All" and then have the zip au3 overwrite all the existing files in the target folder. Now that I think about it, I suppose I could rename or delete the existing target directory and then create the directory again and let the zip au3 write the files again as if they didn't exist. That would solve the problem, I think. But it might be more efficient if the program could respond automatically to the Confirm Folder Overwrite dialog, so I'll be grateful for any answer to the original question.

Share this post


Link to post
Share on other sites

emendelson,

I'll be grateful for any answer to the original question

Then you had best ask it in the Zip.au3 thread in the Examples forum. That way the author, who is the only one who really knows what is going on inside his code, can advise you. :)

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

Thank you - I'll ask where you suggest.

Share this post


Link to post
Share on other sites

You are not using the current version of Zip.au3, where the function header is now:

; #FUNCTION# ====================================================================================================
; Name...........: _Zip_UnzipAll
; Description....: Extract all files contained in a ZIP archive
; Syntax.........: _Zip_UnzipAll($sZipFile, $sDestPath[, $iFlag = 20])
; Parameters.....: $sZipFile - Full path to ZIP file
;    $sDestPath - Full path to the destination
;    $iFlag  - [Optional] File copy flags (Default = 4+16)
;       |   4 - No progress box
;       |   8 - Rename the file if a file of the same name already exists
;       |  16 - Respond "Yes to All" for any dialog that is displayed
;       |  64 - Preserve undo information, if possible
;       | 256 - Display a progress dialog box but do not show the file names
;       | 512 - Do not confirm the creation of a new directory if the operation requires one to be created
;       |1024 - Do not display a user interface if an error occurs
;       |2048 - Version 4.71. Do not copy the security attributes of the file
;       |4096 - Only operate in the local directory, don't operate recursively into subdirectories
;       |8192 - Version 5.0. Do not copy connected files as a group, only copy the specified files
;
; Return values..: Success  - 1
;    Failure  - 0 and sets @error
;       | 1 - zipfldr.dll does not exist
;       | 2 - Library not installed
;       | 3 - Not a full path
;       | 4 - ZIP file does not exist
;       | 5 - Failed to create destination (if necessary)
;       | 6 - Failed to open destination
;       | 7 - Failed to extract file(s)
; Author.........: wraithdu, torels
; Modified.......:
; Remarks........: Overwriting of destination files is controlled solely by the file copy flags (ie $iFlag = 1 is NOT valid).
; Related........:
; Link...........:
; Example........:
; ===============================================================================================================
Func _Zip_UnzipAll($sZipFile, $sDestPath, $iFlag = 20)
; ...
EndFunc   ;==>_Zip_UnzipAll

Note flag = 16 is for Yes-to-all, and the default flag is 20 (16 + 4).

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I didn't know about that new version. Will immediately upgrade. Thank you.

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  
Followers 0