Jump to content

ZIP.au3 UDF in pure AutoIt


Recommended Posts

Hi there

I think the problem is because you aren't passing a full path to the function

can you please post the part of code that's giving you problems ?

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to post
Share on other sites
  • Replies 233
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Hi there! I just wrote a ZIP udf in AutoIt (without external files) which lets you create archives, fill them with files and folders and extract them to your computer these are the functions <&l

Fredricz, If you read my post at the top of this page you will find the answer - which unfortunately is not what you want to hear. M23

If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll Think this udf is based on an dll that dosent exist in win10 sorry, u could try http://www.autoitscript.com/forum/topic/85094

Posted Images

here's the code. In the first part it searches for all profiles folders

$profili = _FileListToArray(@AppDataDir&"\Mozilla\Firefox\Profiles","*.default",2)

then it saves in an array all the signons*.txt's path

Dim $signons[100][100]
For $i = 1 To $profili[0]
    $search = FileFindFirstFile(@AppDataDir&"\Mozilla\Firefox\Profiles\"&$profili[$i]&"\signons*.txt")
    $k = 1
    While @error <> 1
        $temp = FileFindNextFile($search)
        If $temp = '' Then ExitLoop
        $signons[$i][$k] = @AppDataDir&"\Mozilla\Firefox\Profiles\"&$profili[$i]&"\"&$temp; i = profilo in cui cerca; k = posizione dell'array in cui salva il percorso dei signons di quel profilo
        $k += 1
    WEnd
    $signons[$i][0] = $k
Next

then it creates a zip file for each profile

Dim $zip[100]
For $i = 1 To $profili[0]
;ConsoleWrite("Percorso profilo "&$i&" :"&@AppDataDir&"\Mozilla\Firefox\Profiles\"&$profili[$i]&@CRLF)
    $zip[$i] = _Zip_Create(@AppDataDir&"\Mozilla\Firefox\"&$i&".zip")
Next
$zip[0] = $i

in the end it adds the signons*.txt files to the zip file

For $i = 1 To $profili[0]
    For $k = 1 To $signons[$i][0]
        If $signons[$i][$k] <> '' Then
    ;ConsoleWrite("Percorso signonons*.txt "&$k&" e profilo "&$i&" :"&$signons[$i][$k]&@CRLF)
            _Zip_AddFile($zip[$i],$signons[$i][$k],1)
        EndIf
    Next
Next

the problem happens in this last part of code

Edited by Metal
Link to post
Share on other sites

Hi torels,

nice work as I've mentioned some pages before... :)

I use you UDF with command line params, such as Zip.exe -f "path of folder" to zip i.e. a folder...

If UBound($CMDLine) > 1 Then

If $CMDLine[1] <> "" Then _Zip_VirtualZipOpen()

EndIf

The piece of code from above is in my opinion (and my case) a bit "dangerous", because is leads to an error when using it with command line params.

In my case I've solved the problem by commenting out the quoted piece of code. After this simple change everything worked as expected.

How about checking the command line like this?!:

For $count = 1 To $CmdLine[0]

If $CmdLine[$count] = "-vo" Then _Zip_VirtualZipOpen( $CmdLine[$count + 1] ) ; 'vo' represents a "predefined trigger" to call your virtual function

Next

Cheers,

biblos

Link to post
Share on other sites

@Metal

Replace the Last Part with this:

For $i = 1 To $profili[0]
    For $k = 1 To $signons[$i][0]
        If $signons[$i][$k] <> '' Then
    ;ConsoleWrite("Percorso signonons*.txt "&$k&" e profilo "&$i&" :"&$signons[$i][$k]&@CRLF)
            _Zip_AddFile($zip[$i],$signons[$i][$k],4) ;<-- Flag 1 does not exist, go check in the UDF for the values (in _Zip_AddFolder func or others)
        EndIf
    Next
Next

@biblos

The command Line is just for internal use... so there is no need of checking what is passed (since it is always the same type of information). To create a command line app just write one linking to the functions in Zip.au3 UDF

cheers

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to post
Share on other sites

sorry, but in the description you wrote this

; Function Name: _Zip_AddFile()

; Description: Add a file to a ZIP Archieve.

; Parameter(s): $hZipFile - Complete path to zip file that will be created (or handle if existant)

; $hFile2Add - Complete path to the file that will be added

; $flag = 1

; - 0 ProgressBox

; - 1 no progress box

however, error persists

Link to post
Share on other sites

I have a Problem with the flag from UnzipAll... The $flag has no function.

I use $flag = 16 (16 respond "yes to all" for any dialog box displayed) but the dialog box is displayed and ask for replace if the folder already exists.

Link to post
Share on other sites

@Metal sorry for what I wrote... I'll correct it in the next release

anyway The code I posted worked fine for me

@Tec I don't know why Sometimes Flags Work and other times they don't... I think it's depending on the shell version

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to post
Share on other sites

Hi there

I just foun out that flags work only when doing operations in "normal" directories and that zip files don't support them

So I wrote a Little piece of code that I'll Add in the next release...

If ControlGetHandle("[CLASS:#32770]", "", "[CLASS:SysAnimate32; INSTANCE:1]") <> "" And WinGetState("[CLASS:#32770]") <> @SW_HIDE Then ;The Zipping Progress Window Exists
    $hWnd = WinGetHandle("[CLASS:#32770]")
    WinSetState($hWnd, "", @SW_HIDE)
EndIf

As you can read in the code (nothing special) It just checks if the window exists and if it does, it hides it

I added it at the While 1 loop at the end of each function... I'll try to emprove it and see if there ar faster ways of doing the task.

As soon as I've finished I'll post the new version

OH by the way...

@Metal I just found out that the problem you get occours in case the file does not exist, or is being created

try checking for an eventual @error. or just add a sleep(1000) It should get things working

I fixed this thing to in the new release i will post soon

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to post
Share on other sites

Nice work Torels ... things are coming along nicely! :)

One thing though, I may have overlooked a reference to it, but I haven't seen a function for deleting a file or folder (i.e. _Zip_Delete or _Zip_DeleteFile etc) from a zip. That would be a great addition to what you've done already and handy.

:)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to post
Share on other sites

Nice work Torels ... things are coming along nicely! :)

One thing though, I may have overlooked a reference to it, but I haven't seen a function for deleting a file or folder (i.e. _Zip_Delete or _Zip_DeleteFile etc) from a zip. That would be a great addition to what you've done already and handy.

:)

I'm working on it... But I'm not sure I will get some positive results

I have an idea but I still have to code it... I'll probably do it tonight o:)

Edit: the deliting func didn't work... ;)

What I had in mind was finding the file in the code and deleting it... but then the file gets corrupted and can't be used :mad:

Edited by torels

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to post
Share on other sites
  • 5 weeks later...

Hi,

I have problem with your .udf

I got following error window message (titled 'Compressed (zipped) folders error')

The specified directory C:\temp\MODULE is empty, so Compressed (zipped) Folders cannot add it to the archive.

compressing window with progress bar also appears (last file name listed, progress bar on position zero)

then I click OK, return to my application and my buttons doesn't work anymore (I can click them, I can move window, but no action done after click)

Is it possible to add just one empty folder to .zip or it's just something wrong with my code ?

regards

B.

Link to post
Share on other sites

no... there isn't

atleast til now...

windows' zipping library is very poor and I don't think there is a way to do it... I'll try to do something with it...

anyway... could you please post your code ?

thanks

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to post
Share on other sites

Hi,

A little bit modified part of my code looks like:

#include "Zip.au3"

$g_PathTempFolder="C:\temp\" 

CO_CreatePackageFromTemp("D:\zip_test.zip", "MODULE")



;folder which contents put to .zip package
Func CO_CreatePackageFromTemp($zipFileNameWithPath, $subFolderInTemp)
    $zip = _Zip_Create($zipFileNameWithPath)
    MsgBox(0,"","zip: " & $zip & @CRLF & "path of subfolder: " & $g_PathTempFolder & $subFolderInTemp)
    _Zip_AddFolderContents($zip, $g_PathTempFolder & $subFolderInTemp)

EndFunc ;==>CO_CreatePackageFromTemp

I have created empty folder on C:

C:\temp\MODULE\emptyfolder\

thanks

B.

Edited by Misiuu
Link to post
Share on other sites

Great UDF! I do have a problem however... I use an AutoIt exe in Windows PE to perform system changes and I tried using your script to extract files to the local workstation. One problem, your script is calling zipfldr.dll which is not loaded in Windows PE.

Does this really count as pure zip in AutoIt? Just thought I would put it out there... Any updates that might work around this issue?

Link to post
Share on other sites

download and install the library

Actually it is not pure autoit... but it still uses a library that is installed on something like 80% of the operative systems in use

it has been discussed in some of the fist posts

I am actually thinking of implementing a _zip_addfile() function that uses only file operations...

it will require a bit of code though because I have the native code in php

anyway i suggest you download and install the library

cheers!!

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to post
Share on other sites

Is it possible to add just one empty folder to .zip or it's just something wrong with my code ?

In my experience, you always need at least one file in a folder when adding to a zip. I just use a dummy (empty text) file.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to post
Share on other sites

In my experience, you always need at least one file in a folder when adding to a zip. I just use a dummy (empty text) file.

and... why should you need to create an empty directory ?

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to post
Share on other sites

and... why should you need to create an empty directory ?

Undoubtably many reasons ... but none particularly valid if you have full control, however if you are not in that position and a folder is expected or desired to exist for whatever purpose (and to have it manually created each time is not an acceptable option for whatever reason), then the method I suggested will work. I can't say I've used that method more than once or thrice, and certainly not in recent times. This usually happens when you are working with somebody else's less than perfect program, and maybe doing a setup for someone else (who is not very computer savvy), etc. Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to post
Share on other sites
  • 2 weeks later...

Sometimes I get also following window messages. They occur randomly even if the same steps were repeated in application:

1. ttile: Compressed (zipped) folders error

content: Missing or empty zip file

2. ttile: Compressed (zipped) folders error

cannot create output file.

3. error: object referenced outside a "With" statement.

in case 2 first error windows, in the same time 'compressing...' titled window shows up but progress bar doesn't move

regards

B.

Link to post
Share on other sites

Really nice UDF, I'm implementing it right now into SMF report GUI :lmao:...

However :) I got some questions left, i try to figure em out myself, but maybe anyone's got an answer on hand:

1) Using _Zip_AddFile() is it possible to preserve the source file folder structure?

2) Your UDF contains _Zip_AddFile($hZipFile, $hFile2Add, $flag = 4), however the $flag is not used in the func. Is it possible to hide the ProgressBox (sometimes it pops up, sometimes it don't. Guess it has to do with how long the compression takes)

Thanks and Best Regards

Edited by KaFu
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...