Jump to content

Progress bar doing nothing


Recommended Posts

I would like to copy some files using DirCopy(). While doing this I'd like to have a progress bar. I've written the script to do this but unfortunately my AdlibEnable() doesn't seem to jump to my function and therefore my progress bar stays still :ph34r:

Here's my code:

ProgressOn("Windows XP Service Pack 2", "", "Copying setup files to the LAN - please wait...")
$bar = 1
ProgressSet($bar)

BlockInput(1)    ;disable user input
AdlibEnable("UpdateProgressBar", 1000)

FileCopy("wxpsp2\sp2.exe", "F:\Public")
DirCopy("wxpsp2", "F:\Public\wxpsp2", 1) ;copy and overwrite current files

AdlibDisable()
ProgressSet(100, "Finished.", "")
SoundSetWaveVolume(100)
SoundPlay("C:\Windows\Media\Notify.wav")
Sleep(1000);pause or one second so the finished message can be read
ProgressOff()
BlockInput(0);enable user input

MsgBox(0, "Windows XP Service Pack 2", "Finished." & @CR & @CR & "Go to each computer, click Start | Run, SP2 and press Enter")
Exit

; Functions
; ---------
Func UpdateProgressBar()
  $bar = $bar + 1
  If $bar > 100 Then
    $bar = 0
    Send("{UP}") ;press a key to stop the screen saver appearing
  EndIf
  ProgressSet($bar)
EndFunc

Any ideas?

Thanks in advance :(

Michael
Link to comment
Share on other sites

  • Administrators

I would like to copy some files using DirCopy(). While doing this I'd like to have a progress bar. I've written the script to do this but unfortunately my AdlibEnable() doesn't seem to jump to my function and therefore my progress bar stays still  :ph34r:

Here's my code:

ProgressOn("Windows XP Service Pack 2", "", "Copying setup files to the LAN - please wait...")
$bar = 1
ProgressSet($bar)

BlockInput(1)    ;disable user input
AdlibEnable("UpdateProgressBar", 1000)

FileCopy("wxpsp2\sp2.exe", "F:\Public")
DirCopy("wxpsp2", "F:\Public\wxpsp2", 1);copy and overwrite current files

AdlibDisable()
ProgressSet(100, "Finished.", "")
SoundSetWaveVolume(100)
SoundPlay("C:\Windows\Media\Notify.wav")
Sleep(1000);pause or one second so the finished message can be read
ProgressOff()
BlockInput(0);enable user input

MsgBox(0, "Windows XP Service Pack 2", "Finished." & @CR & @CR & "Go to each computer, click Start | Run, SP2 and press Enter")
Exit

; Functions
; ---------
Func UpdateProgressBar()
  $bar = $bar + 1
  If $bar > 100 Then
    $bar = 0
    Send("{UP}");press a key to stop the screen saver appearing
  EndIf
  ProgressSet($bar)
EndFunc

Any ideas?

Thanks in advance  :(

The problem is that Adlib is only executed inbetween lines of the main script. So if the filecopy takes 20 seconds the adlib won't run until it's finished.
Link to comment
Share on other sites

This IS a script language. You will need to Script the solution. Using FileFindFirstFile/FileFindNextFile to load  the files into an array then copy them in a For Loop updating the progress as it goes. You can do it... I believe in you.

Lar.

<{POST_SNAPBACK}>

That sounds interesting, one of these days maybe I'll try it. But I found an easier way of doing it. I have two scripts. Here's the main script:

Run("Progress.exe")

FileCopy("wxpsp2\sp2.exe", "F:\Public")
DirCopy("wxpsp2", "F:\Public\wxpsp2", 1) ;copy and overwrite current files

WinKill("Windows XP Service Pack 2")

Here's the second script called Progress.exe.

WinMinimizeAll()
BlockInput(1)

ProgressOn("Windows XP Service Pack 2", "", "Copying setup files to the LAN - please wait...")
$bar = 1
ProgressSet($bar)

While WinExists("Windows XP Service Pack 2", "Copying")
  Sleep(3000) ;pause to make the progress bar slower
  $bar = $bar + 1
  If $bar > 100 Then
    $bar = 0
    Send("{UP}");press a key to stop the screen saver appearing
  EndIf
  ProgressSet($bar)
WEnd
BlockInput(0)
Exit

The idea is that Progress.exe when run using Run() will continue executing even while the DirCopy is working in the original script. When I want Progress.exe to stop, I kill the window. The Progress.exe while/wend loop ends when it can't see the window anymore thereby closing the Progress.exe program.

It works well enough. It seems a bit slow though. But it's not bad.

Michael

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