Jump to content

How to wait for winzip to end


Recommended Posts

Hi

i am writing a script that

1. takes time stamp

2. open folder

3. select all files, perform right click

4. select 'encrypt' from context menu (third party tool is used here. the tool encrypts all files one by one)

5. take time stamp after step 4 is finished.

the problem is, i am unable to identify when step 4 ends. since the encryption process is from third party, and performs encryption of files one by one, how can i make my script wait for it, and make it know when the encryption ends?

Link to comment
Share on other sites

  • Moderators

rizwanahmed24,

If the 3rd party tool exits when it is finished, you could look to see if its process has terminated by looping ProcessExists. If it restarts for each new file, you might have to make sure it remains closed for a longer period before deeming the whole list to have been completed.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Can U share ur code which is written yet by U?

i dont think the code will help here. but here it is anyways, this is my first code in autoit, therefore..... yes u understand wht..

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.0.0
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <GUIConstantsEx.au3>


;decalartoin
Global $margin_label_left = 10
Global $margin_button_left = 100
Global $height = 20
Global $button_width = 50


GUICreate("Test-Secure File", 300, 150) 

;create count label and text box
$btn = GUICtrlCreateLabel("Count", $margin_label_left, 10)
Global $tbx_Count = GUICtrlCreateInput("5", $margin_button_left, 10, 70, $height);

;create size label and text box
GUICtrlCreateLabel("Size in KBs", $margin_label_left, 32)
Global $tbx_Size = GUICtrlCreateInput("5", $margin_button_left, 32, 70, $height);


;perform and exit buttons
$btn_Perform = GUICtrlCreateButton("Perform", $margin_button_left, 100,$button_width, $height);
$btn_Exit = GUICtrlCreateButton("Exit", $margin_button_left + $button_width + 20, 100, $button_width, $height)


GUISetState(@SW_SHOW)
while 1
    $GUImsg = GUIGetMsg()
    
    Select
        
        case $GUImsg = $btn_Perform
            Local $p = GenerateRandomFiles(GUICtrlRead($tbx_Count), GUICtrlRead($tbx_Size))
            $timeStart = TimerInit()
            SecureFiles($p)
            
            if ProcessExists("SecureFile") Then
            Else
                MsgBox(0, "securing ended", "securing ended")
            EndIf
            
            
            
            $time = TimerDiff($timeStart)           
            $timeEnd = $time / 1000 
            
    ;MsgBox(0, "time taken in seconds", $time)
                                
        case $GUImsg = $btn_Exit
            ExitLoop
            
    EndSelect
WEnd
        

Func SecureFiles($dirPath)

    ShellExecuteWait($dirPath)
    send("{Down}")  
    Send("^a")
    send("+{F10}")
    send("{Down 2}")    
    send ("{enter}")
        
EndFunc


#cs 
u dont need to look at it, its a small program to generate random files 
#ce
Func GenerateRandomFiles( $count,  $size)

    $fileGeneratorProcess = ShellExecute("FileGeneratorTool.exe")
    WinWaitActive("File Generator Tool")
    Local $dirPath = @ScriptDir & "\test data"
    
    DirCreate($dirPath)
    Send($dirPath)
    Send("{TAB 2}")
    Send($count)
    Send("{TAB}")
    Send($size)
    Send("{TAB}")
    Send("{ENTER}")
    ProcessWait("FileGeneratorTool.exe")    
    Send("!{F4}")
    
    return $dirPath
    
EndFunc
Edited by rizwanahmed24
Link to comment
Share on other sites

rizwanahmed24,

If the 3rd party tool exits when it is finished, you could look to see if its process has terminated by looping ProcessExists. If it restarts for each new file, you might have to make sure it remains closed for a longer period before deeming the whole list to have been completed.

M23

thanks Melba23. 'ProcessExists' did the trick

Link to comment
Share on other sites

just to give a different solution for further reference

you could make an MD5 hash of the files while they aren't encrypted and then make hashes every 5 seconds or so and check until all the hashes are different :(

or only the hash of the last file is different from the hash once it's encrypted ^_^;)

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