Jump to content

progress meter


Recommended Posts

hello,

i would like to update my progress bar to basically move side to side (like battlestar galactica cylon laser) :D

during the install, and then close after install complete.

not having a progress bar for each part of the install ..showing constant movement during install.

hope this makes sense and thank you for any assistance.

ciao

code:

;--------------- software install
;-
;-
;-
;----------------------------------------

;----------   splash for update.exe
$destination = "\\server\folder\script\Images\folder1\photo.gif"

SplashImageOn("Software", $destination,477,345)
Sleep(5000)
SplashOff()
;----------   start of update.exe
ProgressOn ("Software", "Aug2008Udate", "PLEASE WAIT...")
Sleep(1000)
Run('\\server\folder2\folder\Aug2008Update\update.exe')
Sleep (3000)
ProgressSet( 20,"20 %")
WinWaitActive ("Software - InstallShield Wizard", "Welcome for Software")
ProgressSet( 40,"40 %")
WinActivate("Software - InstallShield Wizard")
Sleep(1000)
Send("!n")
WinWaitActive ("Software", "Welcome for Software")
ProgressSet( 60,"60 %")
Sleep(1000)
WinActivate("Software")
Send("!n")
ProgressSet( 80,"80 %")
WinWaitActive ("Software", "Setup Complete")
Sleep(2000)
Send ("{ENTER}")
;--------   update.exe install complete
ProgressSet( 100,"100 %","Software Aug2008Update Complete!")

;--------   splash of test_other install
$destination = "\\server\folder\folder2\Images\testing\folder3.gif"

SplashImageOn("software", $destination,477,345)
Sleep(5000)
SplashOff()
;--------   start of test_other install
ProgressOn ("software", "Testing", "PLEASE WAIT...")
Sleep(1000)
Run('\\server\folder\testing\folder3\test_other')
ProgressSet( 5,"5 %")
Sleep(500)
ProgressSet( 6,"6 %")
Sleep(500)
ProgressSet( 7,"7 %")
Sleep(500)
ProgressSet( 8,"8 %")
Sleep(500)
ProgressSet( 9,"9 %")
Sleep(1000)
ProgressSet( 10,"10 %")
WinWaitNotActive("wizard", "Preparing to Install...")
ProgressSet( 15,"15 %")
WinWaitActive("test computer 7.2 Aug08 - wizard", "Welcome to the wizard!")
ProgressSet( 20,"20 %")
WinActivate("test computer 7.2 Aug08 - wizard")
Sleep(2000)
Send("!n")
WinWaitActive("test computer 7.2 Aug08 - wizard", "License Agreement")
WinActivate("test computer 7.2 Aug08 - wizard")
Sleep(1000)
Send("{UP}")
ProgressSet( 40,"40 %")
Sleep(1000)
ProgressSet( 50,"50 %")
Send("!n")
WinWaitActive("test computer 7.2 Aug08 - wizard", "Customer Information")
Sleep(2000)
WinActivate("test computer 7.2 Aug08 - wizard")
ProgressSet( 60,"60 %")
Send("test")
Sleep(500)
Send ("{TAB}")
Send("test")
Sleep(1000)
Send("!n")
WinWaitActive("test computer 7.2 Aug08 - wizard", "Destination Folder")
Sleep(2000)
WinActivate("test computer 7.2 Aug08 - wizard")
ProgressSet( 70,"70 %")
Send("!n")
WinWaitActive("test computer 7.2 Aug08 - wizard", "Ready to Install the Program")
Sleep(2000)
WinActivate("test computer 7.2 Aug08 - wizard")
ProgressSet( 80,"80 %")
Send("!i")
WinWaitNotActive("test computer 7.2 Aug08 - wizard", "Installing test computer")
ProgressSet( 90,"90 %")
WinWaitActive("test computer 7.2 Aug08 - wizard", "wizard Completed")
WinActivate("test computer 7.2 Aug08 - wizard")
Sleep(3000)
Send("!f")

;---------   software computer install complete
ProgressSet( 100,"100 %","software test complete!")
Link to comment
Share on other sites

I don't think you can do that with th einbuilt ProgressOn function. You need to create your own progress bar with the $PBM_SETMARQUEE style.

#include <guiconstants.au3>
#include <constants.au3>
#include <GuiStatusBar.au3>
#include <progressconstants.au3>


$g = GUICreate("test")
$l = GUICtrlCreateLabel("Running",20,40,120,21)
GUISetState()

$hp = _UpdateProgbar()
SBOnOff($hp,True)
Sleep(6000)
GUICtrlSetData($l,"Now stopped")
SBOnOff($hp,False)

Sleep(5000)


Func _UpdateProgbar($hSb=0)
   ;creates the progress bar
    Local $pbStyle = $PBS_MARQUEE,$hpb

    If @OSTYPE = "WIN32_WINDOWS"  Then $pbStyle = $PBS_SMOOTH
    
    $progress = GUICtrlCreateProgress(0, 0, 200,30, $pbStyle)

    $hpb = GUICtrlGetHandle($progress)

    return $hpb
EndFunc

Func SBOnOff($bar, $onoff)
    If @OSTYPE = "WIN32_WINDOWS"  Then return;no marquee effect to stop

    _SendMessage($bar, $PBM_SETMARQUEE, $onoff, 200); marquee works on Win XP and above
EndFunc
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Something like this? It's just demo code and you can play with the numbers to get what you want.

;
$iProgress = 0
Run('\\server\folder\testing\folder3\test_other')
ProgressOn ("software", "Testing", "PLEASE WAIT...")
While $Run
    ProgressSet( $iProgress,$iProgress & " %")
    $iProgress += 1
    If $iProgress >= 100 Then $iProgress = 0
    Sleep(50);; Change this to modify the refresh rate
Wend
;

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Something like this? It's just demo code and you can play with the numbers to get what you want.

;
$iProgress = 0
Run('\\server\folder\testing\folder3\test_other')
ProgressOn ("software", "Testing", "PLEASE WAIT...")
While $Run
    ProgressSet( $iProgress,$iProgress & " %")
    $iProgress += 1
    If $iProgress >= 100 Then $iProgress = 0
    Sleep(50);; Change this to modify the refresh rate
Wend
;
GEOSoft,

thanks for the input

i also declared the $Run variable.

starts the script and progress fine, but the progress bar just loops, and the script is doa.

the looping of the progress bar is just what i was looking for, but all i need now is

to have the script continue on, and kill the progress after script is done. (ProgressOff() ???)

updated code:

$Run = '\\server\folder1\test72\folder2\test2.exe'
$iProgress = 0
Run('\\server\folder1\test72\folder2\test2.exe')
ProgressOn ("software", "Testing", "PLEASE WAIT...")
While $Run
    ProgressSet( $iProgress,$iProgress & " %")
    $iProgress += 1
    If $iProgress >= 100 Then $iProgress = 0
    Sleep(50);; Change this to modify the refresh rate
Wend

Sleep(1000)
WinWaitActive ("test Client Update - setup", "Welcome to the setup for test Client Update")
WinActivate("test Client Update - setup")
Sleep(1000)
Send("!n")
WinWaitActive ("test Client Update", "Welcome to the setup for test Client Update")
Sleep(1000)
WinActivate("test Client Update")
Send("!n")
WinWaitActive ("test Client Update", "Setup Complete")
Sleep(2000)
Send ("{ENTER}")

ProgressOff()
Link to comment
Share on other sites

I didn't add the ProgressOff() after the Wend. Like I stated, "Demo Code".

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Maybe.... ( using GEO's stuff too)

Global $Hold_GUI

ProgOn()

Run('\\server\folder1\test72\folder2\test2.exe')
Sleep(1000)
WinWaitActive("test Client Update - setup", "Welcome to the setup for test Client Update")
WinActivate("test Client Update - setup")
Sleep(1000)
Send("!n")
WinWaitActive("test Client Update", "Welcome to the setup for test Client Update")
Sleep(1000)
WinActivate("test Client Update")
Send("!n")
WinWaitActive("test Client Update", "Setup Complete")
Sleep(2000)
Send("{ENTER}")

ProgOff()

Func ProgOn()
    Local $file_loc = @ScriptDir & "\Progresser.au3"

    Dim $Hold_GUI = GUICreate("HOLD_ON")
    GUISetState(@SW_HIDE, $Hold_GUI)

    $a = ""
    $a = "$iProgress = ''" & @CRLF
    $a &= 'ProgressOn ("software", "Testing", "PLEASE WAIT...")' & @CRLF
    $a &= 'While WinExists("HOLD_ON")' & @CRLF
    $a &= 'ProgressSet( $iProgress,$iProgress & " %")' & @CRLF
    $a &= '$iProgress += 1' & @CRLF
    $a &= 'If $iProgress >= 100 Then $iProgress = 0' & @CRLF
    $a &= 'Sleep(100);; Change this to modify the refresh rate' & @CRLF
    $a &= 'Wend' & @CRLF

    FileWrite($file_loc, $a)

    If @Compiled = 1 Then
        $file_exe = FileGetShortName(@AutoItExe & ' /AutoIt3ExecuteScript "' & $file_loc & '"')
        Run($file_exe)
    Else
        $file_au3 = FileGetShortName($file_loc)
        Run(@AutoItExe & " " & $file_au3, "", @SW_HIDE)
    EndIf

EndFunc   ;==>ProgOn


Func ProgOff()
    GUIDelete($Hold_GUI)
    FileDelete(@ScriptDir & "\Progresser.au3")
EndFunc   ;==>ProgOff

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

I didn't add the ProgressOff() after the Wend. Like I stated, "Demo Code".

sorry.

i know that you did not add the progressoff().

just trying to find a way to have the script continue after the progress starts, and then exit at the end.

no worries.

thanks again.

Link to comment
Share on other sites

I see that you are working with an Active window. This will place the Progress GUI in the upper left corner

Global $Hold_GUI

ProgOn()

Sleep(10000)

ProgOff()

Func ProgOn()
    Local $file_loc = @ScriptDir & "\Progresser.au3"

    Dim $Hold_GUI = GUICreate("HOLD_ON")
    GUISetState(@SW_HIDE, $Hold_GUI)

    $a = ""
    $a = "$iProgress = ''" & @CRLF
    $a &= 'ProgressOn ("software", "Testing", "PLEASE WAIT...", 20, 20)' & @CRLF
    $a &= 'While WinExists("HOLD_ON")' & @CRLF
    $a &= 'ProgressSet( $iProgress,$iProgress & " %")' & @CRLF
    $a &= '$iProgress += 1' & @CRLF
    $a &= 'If $iProgress >= 100 Then $iProgress = 0' & @CRLF
    $a &= 'Sleep(100);; Change this to modify the refresh rate' & @CRLF
    $a &= 'Wend' & @CRLF

    FileWrite($file_loc, $a)

    If @Compiled = 1 Then
        $file_exe = FileGetShortName(@AutoItExe & ' /AutoIt3ExecuteScript "' & $file_loc & '"')
        Run($file_exe)
    Else
        $file_au3 = FileGetShortName($file_loc)
        Run(@AutoItExe & " " & $file_au3, "", @SW_HIDE)
    EndIf

EndFunc   ;==>ProgOn


Func ProgOff()
    GUIDelete($Hold_GUI)
    FileDelete(@ScriptDir & "\Progresser.au3")
EndFunc   ;==>ProgOff

8)

NEWHeader1.png

Link to comment
Share on other sites

YW

By the way, I would change the line

ProgressSet( $iProgress,$iProgress & " %")

To

ProgressSet( $iProgress, "")

Reason? The progress goes up to 100% and then resets to 0% for each cycle so the $iProgress & " %" is really of no usable meaning.

A better way of doing this may have been to create a separate GUI for the Progress and use the GUI Progress control along with GUICtrlSetData() and possibly GUICtrlRead()

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

YW

By the way, I would change the line

ProgressSet( $iProgress,$iProgress & " %")

To

ProgressSet( $iProgress, "")

Reason? The progress goes up to 100% and then resets to 0% for each cycle so the $iProgress & " %" is really of no usable meaning.

A better way of doing this may have been to create a separate GUI for the Progress and use the GUI Progress control along with GUICtrlSetData() and possibly GUICtrlRead()

Possibly... :D

:o

8)

NEWHeader1.png

Link to comment
Share on other sites

YW

By the way, I would change the line

ProgressSet( $iProgress,$iProgress & " %")

To

ProgressSet( $iProgress, "")

Reason? The progress goes up to 100% and then resets to 0% for each cycle so the $iProgress & " %" is really of no usable meaning.

A better way of doing this may have been to create a separate GUI for the Progress and use the GUI Progress control along with GUICtrlSetData() and possibly GUICtrlRead()

i will take out the %. good point.

will this script still run ok if i compile it first, then run on a computer that does not have autoit? so long i don't have " #include " ..right?

Link to comment
Share on other sites

ok. cool.

ciao

For future reference, when you compile a script, any files that have been #included are truely included in the compiled file. Therefore #include has absolutly no bearing on whether or not it will work compiled. If it works as a script then it should work compiled.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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