Jump to content

File progress window


Recommended Posts

Is there any way to have a file progress window show up while files are copying via a Autoit script.

CODE
$file = FileExists ("c:\program files\activecontrol\1.txt")

If $file = 0 Then

MsgBox (262208, "Active Control", "Active Control is currently out of date. Please click OK to download the newest version. Another window will apear when the download is complete.", 10)

FileCopy ("\\10.0.0.2\Activecontrol\current\*.*", "C:\program files\activecontrol\", 9) ; While this is going I would like to see a file transfer box if possiable, or maybe an instalation window that says that it is installing and shows a status bar on the percent completed.

MsgBox (262208, "Completed", "Active Control is up to date now please press OK")

Else

$datew = FileGetTime ("c:\program files\activecontrol\1.txt", 0)

$datesrvr = FileGetTime ("\\10.0.0.2\activecontrol\current\1.txt", 0)

$WMMDDYYYY = $datew[1] & $datew[2] & $datew[0] & $datew[3] & $datew[4]

$SMMDDYYYY = $datesrvr[1] & $datesrvr[2] & $datesrvr[0] & $datesrvr[3] & $datesrvr[4]

if $WMMDDYYYY < $SMMDDYYYY Then

MsgBox (262208, "Active Control", "Active Control is currently out of date. Please click OK to download the newest version. Another window will apear when the download is complete.", 10)

FileCopy ("\\10.0.0.2\Activecontrol\current\*.*", "C:\program files\activecontrol\", 9) ; While this is going I would like to see a file transfer box if possiable, or maybe an instalation window that says that it is installing and shows a status bar on the percent completed.

MsgBox (262208, "Completed", "Active Control is now up to date, please press OK")

Else

Exit

EndIf

EndIf

Link to comment
Share on other sites

Look here

_FileCopy("\\10.0.0.2\Activecontrol\current\*.*", "C:\program files\activecontrol\")

Func _FileCopy($fromFile,$tofile)

Local $FOF_RESPOND_YES = 16

Local $FOF_SIMPLEPROGRESS = 256

$winShell = ObjCreate("shell.application")

$winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES)

EndFunc

I tired to use this for my code but it didn't suppress the propting for each file. I would like it to not ask the user to overwrite it would just do it. Any help would be greatly appreciated.

Thanks,

Jon

Link to comment
Share on other sites

_FileCopy("\\10.0.0.2\Activecontrol\current\*.*", "C:\program files\activecontrol\")

Func _FileCopy($fromFile,$tofile)

Local $FOF_RESPOND_YES = 16

Local $FOF_SIMPLEPROGRESS = 256

$winShell = ObjCreate("shell.application")

$winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES)

EndFunc

I tired to use this for my code but it didn't suppress the propting for each file. I would like it to not ask the user to overwrite it would just do it. Any help would be greatly appreciated.

Thanks,

Jon

You can use more flags:

;~ 4 Do not display a progress dialog box.

;~ 8 Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.

;~ 16 Respond with "Yes to All" for any dialog box that is displayed.

;~ 64 Preserve undo information, if possible.

;~ 128 Perform the operation on files only if a wildcard file name (*.*) is specified.

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

;~ 9182 Version 5.0. Do not copy connected files as a group. Only copy the specified files.

Edited by Zedna
Link to comment
Share on other sites

Jonniemac315, I just tested the script you posted (#390901) and what is the problem?

I doesn't ask me anything.

Spoke too soon. It does not select Yes To All. Zedna, what are you saying? Are you saying it should work?

According to http://msdn2.microsoft.com/en-us/library/ms630707.aspx, 16 should work... odd. Why isn't it working?

Edited by JohnBailey
A decision is a powerful thing
Link to comment
Share on other sites

Jonniemac315, I just tested the script you posted (#390901) and what is the problem?

I doesn't ask me anything.

Spoke too soon. It does not select Yes To All. Zedna, what are you saying? Are you saying it should work?

According to http://msdn2.microsoft.com/en-us/library/ms630707.aspx, 16 should work... odd. Why isn't it working?

Maybe I have the 16 in the wrong spot. Is this where it is supposed to go?

$winShell.namespace($tofile).CopyHere($fromFile,16)

Link to comment
Share on other sites

_FileCopy1("\\10.0.0.2\Activecontrol\current\1.txt", "C:\program files\activecontrol\")
_FileCopy2("\\10.0.0.2\Activecontrol\current\ActiveControl.mdb", "C:\program files\activecontrol\")
_FileCopy3("\\10.0.0.2\Activecontrol\current\Control.ico", "C:\program files\activecontrol\")
_FileCopy4("\\10.0.0.2\Activecontrol\current\Security.mdw", "C:\program files\activecontrol\")

$file = FileExists ("c:\program files\activecontrol\1.txt")
If $file = 0 Then
    MsgBox (262208, "Active Control", "Active Control is currently out of date. Please click OK to download the newest version. Another window will apear when the download is complete.", 10)
            Func _FileCopy1($fromFile,$tofile) 
                $winShell = ObjCreate("shell.application")
                $winShell.namespace($tofile).CopyHere($fromFile,272)
            EndFunc
            Func _FileCopy2($fromFile,$tofile) 
                $winShell = ObjCreate("shell.application")
                $winShell.namespace($tofile).CopyHere($fromFile,272)
            EndFunc
            Func _FileCopy3($fromFile,$tofile) 
                $winShell = ObjCreate("shell.application")
                $winShell.namespace($tofile).CopyHere($fromFile,272)
            EndFunc
            Func _FileCopy4($fromFile,$tofile) 
                $winShell = ObjCreate("shell.application")
                $winShell.namespace($tofile).CopyHere($fromFile,272)
            EndFunc
    MsgBox (262208, "Completed", "Active Control is up to date now please press OK")
Else
$datew = FileGetTime ("c:\program files\activecontrol\1.txt", 0)
$datesrvr = FileGetTime ("\\10.0.0.2\activecontrol\current\1.txt", 0)
$WMMDDYYYY = $datew[1] & $datew[2] & $datew[0] & $datew[3] & $datew[4]
$SMMDDYYYY = $datesrvr[1] & $datesrvr[2] & $datesrvr[0] & $datesrvr[3] & $datesrvr[4]
    If $WMMDDYYYY < $SMMDDYYYY Then
        MsgBox (262208, "Active Control", "Active Control is currently out of date. Please click OK to download the newest version. Another window will apear when the download is complete.", 10)
            Func _FileCopy1($fromFile,$tofile) 
                $winShell = ObjCreate("shell.application")
                $winShell.namespace($tofile).CopyHere($fromFile,272)
            EndFunc
            Func _FileCopy2($fromFile,$tofile) 
                $winShell = ObjCreate("shell.application")
                $winShell.namespace($tofile).CopyHere($fromFile,272)
            EndFunc
            Func _FileCopy3($fromFile,$tofile) 
                $winShell = ObjCreate("shell.application")
                $winShell.namespace($tofile).CopyHere($fromFile,272)
            EndFunc
            Func _FileCopy4($fromFile,$tofile) 
                $winShell = ObjCreate("shell.application")
                $winShell.namespace($tofile).CopyHere($fromFile,272)
            EndFunc
        MsgBox (262208, "Completed", "Active Control is now up to date, please press OK")
    Else
        Exit
    EndIf
EndIf

Figured it out you can't use a wild card for the FromFile After I just put in a single file it worked great.

Thanks for all the help.

Okay it worked by its self but once I put it into the code it broke my code please help

Link to comment
Share on other sites

Figured it out you can't use a wild card for the FromFile After I just put in a single file it worked great.

Thanks for all the help.

oh wow so that's the solution! Interesting that it wasn't noted (at least what I could tell). It's also interesting that it has to be that way.

A decision is a powerful thing
Link to comment
Share on other sites

I get the error C:\Documents and Settings\VPCAdmin.RAMMINC\Desktop\update.au3 (9) : ==> "If" statement has no matching "EndIf" statement.:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\VPCAdmin.RAMMINC\Desktop\update.au3"

C:\Documents and Settings\VPCAdmin.RAMMINC\Desktop\update.au3 (9) : ==> "If" statement has no matching "EndIf" statement.:

Func _FileCopy1($fromFile,$tofile)

>Exit code: 1 Time: 0.217

Opps forgot some stuff.

Link to comment
Share on other sites

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\VPCAdmin.RAMMINC\Desktop\update.au3"

C:\Documents and Settings\VPCAdmin.RAMMINC\Desktop\update.au3 (9) : ==> "If" statement has no matching "EndIf" statement.:

Func _FileCopy1($fromFile,$tofile)

>Exit code: 1 Time: 0.217

Opps forgot some stuff.

Why are you putting Funcs inside an if statement.... I'm totally sure on this with AU3, but I know in other languages you can't do that because they are defined first regardless of their location.

A decision is a powerful thing
Link to comment
Share on other sites

essentially, you should even be able to do what you've done... at least that's my understanding. Just rename your functions to have 8 total and reference them in your script.

I'm not sure what you are saying to do is there any way that you could show me just one so I can learn that.

Thanks in advance.

Link to comment
Share on other sites

Some Suggestions

First of all, function need to be separate from your "process" (see example below). Second of all, if you have near similar functions that do nearly the same thing but have a small variant, use parameters - this will simplify your script. If you don't know (and you might), parameters are the vars in the function's parenthesis. I'm not totally sure what you're wanting to do, but this should at least show you what you might want to be doing. Putting functions in the process doesn't matter (except for generating bugs), because the functions are defined before the process runs and then are later called. That is why I'm able to put the function at the bottom. I'm sorry if you know all of this and I'm just "preaching to the choir.

Local $file = FileExists ("c:\program files\activecontrol\1.txt")
If $file = 0 Then
    MsgBox (262208, "Active Control", "Active Control is currently out of date. Please click OK to download the newest version. Another window will apear when the download is complete.", 10)
    _FileCopy("\\10.0.0.2\Activecontrol\current\1.txt", "C:\program files\activecontrol\")
    _FileCopy("\\10.0.0.2\Activecontrol\current\ActiveControl.mdb", "C:\program files\activecontrol\")
    _FileCopy("\\10.0.0.2\Activecontrol\current\Control.ico", "C:\program files\activecontrol\")
    _FileCopy("\\10.0.0.2\Activecontrol\current\Security.mdw", "C:\program files\activecontrol\")
    MsgBox (262208, "Completed", "Active Control is up to date now please press OK")
Else
    $datew = FileGetTime ("c:\program files\activecontrol\1.txt", 0)
    $datesrvr = FileGetTime ("\\10.0.0.2\activecontrol\current\1.txt", 0)
    $WMMDDYYYY = $datew[1] & $datew[2] & $datew[0] & $datew[3] & $datew[4]
    $SMMDDYYYY = $datesrvr[1] & $datesrvr[2] & $datesrvr[0] & $datesrvr[3] & $datesrvr[4]
    If $WMMDDYYYY < $SMMDDYYYY Then
        MsgBox (262208, "Active Control", "Active Control is currently out of date. Please click OK to download the newest version. Another window will apear when the download is complete.", 10)
        _FileCopy("\\10.0.0.2\Activecontrol\current\1.txt", "C:\program files\activecontrol\")
        _FileCopy("\\10.0.0.2\Activecontrol\current\ActiveControl.mdb", "C:\program files\activecontrol\")
        _FileCopy("\\10.0.0.2\Activecontrol\current\Control.ico", "C:\program files\activecontrol\")
        _FileCopy("\\10.0.0.2\Activecontrol\current\Security.mdw", "C:\program files\activecontrol\")
        MsgBox (262208, "Completed", "Active Control is now up to date, please press OK")
    Else
        Exit
    EndIf
EndIf

 Func _FileCopy($fromFile,$tofile, $fc_flag=272)
    $winShell = ObjCreate("shell.application")
    $winShell.namespace($tofile).CopyHere($fromFile,$fc_flag)
EndFunc
A decision is a powerful thing
Link to comment
Share on other sites

Some Suggestions

First of all, function need to be separate from your "process" (see example below). Second of all, if you have near similar functions that do nearly the same thing but have a small variant, use parameters - this will simplify your script. If you don't know (and you might), parameters are the vars in the function's parenthesis. I'm not totally sure what you're wanting to do, but this should at least show you what you might want to be doing. Putting functions in the process doesn't matter (except for generating bugs), because the functions are defined before the process runs and then are later called. That is why I'm able to put the function at the bottom. I'm sorry if you know all of this and I'm just "preaching to the choir.

Local $file = FileExists ("c:\program files\activecontrol\1.txt")
If $file = 0 Then
    MsgBox (262208, "Active Control", "Active Control is currently out of date. Please click OK to download the newest version. Another window will apear when the download is complete.", 10)
    _FileCopy("\\10.0.0.2\Activecontrol\current\1.txt", "C:\program files\activecontrol\")
    _FileCopy("\\10.0.0.2\Activecontrol\current\ActiveControl.mdb", "C:\program files\activecontrol\")
    _FileCopy("\\10.0.0.2\Activecontrol\current\Control.ico", "C:\program files\activecontrol\")
    _FileCopy("\\10.0.0.2\Activecontrol\current\Security.mdw", "C:\program files\activecontrol\")
    MsgBox (262208, "Completed", "Active Control is up to date now please press OK")
Else
    $datew = FileGetTime ("c:\program files\activecontrol\1.txt", 0)
    $datesrvr = FileGetTime ("\\10.0.0.2\activecontrol\current\1.txt", 0)
    $WMMDDYYYY = $datew[1] & $datew[2] & $datew[0] & $datew[3] & $datew[4]
    $SMMDDYYYY = $datesrvr[1] & $datesrvr[2] & $datesrvr[0] & $datesrvr[3] & $datesrvr[4]
    If $WMMDDYYYY < $SMMDDYYYY Then
        MsgBox (262208, "Active Control", "Active Control is currently out of date. Please click OK to download the newest version. Another window will apear when the download is complete.", 10)
        _FileCopy("\\10.0.0.2\Activecontrol\current\1.txt", "C:\program files\activecontrol\")
        _FileCopy("\\10.0.0.2\Activecontrol\current\ActiveControl.mdb", "C:\program files\activecontrol\")
        _FileCopy("\\10.0.0.2\Activecontrol\current\Control.ico", "C:\program files\activecontrol\")
        _FileCopy("\\10.0.0.2\Activecontrol\current\Security.mdw", "C:\program files\activecontrol\")
        MsgBox (262208, "Completed", "Active Control is now up to date, please press OK")
    Else
        Exit
    EndIf
EndIf

 Func _FileCopy($fromFile,$tofile, $fc_flag=272)
    $winShell = ObjCreate("shell.application")
    $winShell.namespace($tofile).CopyHere($fromFile,$fc_flag)
EndFunc

Nope don't know any of this I have just started writing code about a month ago so everything that gets posted here is a big help.

Thanks alot,

Jon

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