Jump to content

Progress bar...


Recommended Posts

Hi again,

I got a small problem, i need a progress bar, while running part of my script.

In my script i got a function called "Testing", and since it take some time, i need to have a progress bar, showing the user something is happening.

I tried the code below, wich worked nice, but it does not run together with the script, instead is just pausing the script, and when its done, it then start the "Testing".

Would it be easier to make a GUI with this, or can i make the "ProgressOn" run parallel with the rest?

ProgressOn("ADSL Status", "Checking ADSL status.", "0 percent")

For $i = 10 to 100 step 10

sleep(1000)

ProgressSet( $i, $i & " percent")

Next

ProgressSet(100 , "Done", "Complete")

sleep(500)

ProgressOff()

Were ever i lay my script is my home...

Link to comment
Share on other sites

I'm doing a testing script as well. It starts several applications one after the other. Therefor i wrote a control script, that has a loop in it, "RunWait"ing the individual script files. I built the progress bar into that loop (just like in your example), so after RunWait returns, a variable (and so the progress bar) will be incremented, before the next application will be started. So the shown progress is "application(s) tested".

Basically let the progress bar "use" another loop, that controls the rest. If you can't unitize your script like that, maybe you can send updates to a seperate progress bar script at specific points in your script.

Could you explain what you are doing, might be interesting for my script (though i base that assumption only on the word "testing")? :D

[EDIT]Should have read your whole post. But what i've written above still fits the problem. If you have a single loop in the Testing function, built the progress bar into it (at least the ProgressSet() function). If you haven't (though i assume you have, why should the script take much time if you haden't), try sending manual updates.[/EDIT]

Edited by Proof
Link to comment
Share on other sites

Thanks for the input, i did not really get what you mean, but it was nice anyway :D

My script this time is as follow:

First it test the computer, and collect different settings such as,

**Here is were i need the progress bar to start**

Local IP

Check if it can contact ISP (by pinging ISP)

Check if DNS is active (by pinging a URL)

Check if Proxy is disabled (by reading Regedit)

Check if Temp Internet files is deleted (Still no soloution)

**Here is were i need the progress bar to end**

You will get a GUI with red and green lights depending on what the return is from the questions above. You will also get a button, "Fix".

When you press Fix,

Disable Proxy (by writting to Regedit)

Delete Temp Ineternet files (No soloution yet)

Run the Testing again, if all lights green then start IE and go to ISP login site.

This will to 90% help the users to solve their own ADSL problem, since above is the most common problem we have. If its not solved the problem, our helpdesk will know directly were the problem is.

Were ever i lay my script is my home...

Link to comment
Share on other sites

Could someone please help me to update my progress bar at the correct places.

The places were i want the progress to "move" is marked with *******

Func Testing();Will test your settings

ProgressOn("ADSL Status", "Checking ADSL status.", "0 percent")
For $i = 10 to 100 step 10
   sleep(1000)
   ProgressSet( $i, $i & " percent")
Next

    IniWrite($SD & "adsl.ini", "ADSL", "Local IP", @IPAddress1)
*********
Global $var = RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable")
  IniWrite($SD & "adsl.ini", "ADSL", "Proxy", $var)
*********
;----------------------Telia--------------------------
    $iRetCode = RunWait( $sCmd & " " & $sCmdParm & " " & $SOption,"",@SW_hide)

    If $IRetCode = 1 Then
  TrayTip("Connection Error!","No contact with Telia" & " at : " & @HOUR & ":" & @MIN & ":" & @SEC ,25, 3)
  IniWrite($SD & "adsl.ini", "ADSL", "Telia", "No")
    Else
  IniWrite($SD & "adsl.ini", "ADSL", "Telia", "Ok")
    EndIF
*********
;----------------------DNS----------------------------
    $iRetCode = RunWait( $sCmd & " " & "www.dn.se" & " " & $SOption,"",@SW_hide)

    If $IRetCode = 1 Then
  TrayTip("Connection Error!","No contact with Telia" & " at : " & @HOUR & ":" & @MIN & ":" & @SEC ,25, 3)
  IniWrite($SD & "adsl.ini", "ADSL", "DNS", "No")
    Else
  IniWrite($SD & "adsl.ini", "ADSL", "DNS", "Ok")
    EndIF
**********
FileSetAttrib($SD & "*.ini", "+H")
**********
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()

EndFunc

Thanks in advance

Were ever i lay my script is my home...

Link to comment
Share on other sites

Just remove

For $i = 10 to 100 step 10
  sleep(1000)
  ProgressSet( $i, $i & " percent")
Next

section and replace **** lines with ProgressSet and some hardcoded values. Like this:

Func Testing();Will test your settings

ProgressOn("ADSL Status", "Checking ADSL status.", "0 percent")

IniWrite($SD & "adsl.ini", "ADSL", "Local IP", @IPAddress1)
ProgressSet( 20, "20  percent")
Global $var = RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyEnable")
 IniWrite($SD & "adsl.ini", "ADSL", "Proxy", $var)
ProgressSet( 40, "40  percent")
;----------------------Telia--------------------------
$iRetCode = RunWait( $sCmd & " " & $sCmdParm & " " & $SOption,"",@SW_hide)

If $IRetCode = 1 Then
 TrayTip("Connection Error!","No contact with Telia" & " at : " & @HOUR & ":" & @MIN & ":" & @SEC ,25, 3)
 IniWrite($SD & "adsl.ini", "ADSL", "Telia", "No")
Else
 IniWrite($SD & "adsl.ini", "ADSL", "Telia", "Ok")
EndIF
ProgressSet( 60, "60  percent")
;----------------------DNS----------------------------
$iRetCode = RunWait( $sCmd & " " & "www.dn.se" & " " & $SOption,"",@SW_hide)

If $IRetCode = 1 Then
 TrayTip("Connection Error!","No contact with Telia" & " at : " & @HOUR & ":" & @MIN & ":" & @SEC ,25, 3)
 IniWrite($SD & "adsl.ini", "ADSL", "DNS", "No")
Else
 IniWrite($SD & "adsl.ini", "ADSL", "DNS", "Ok")
EndIF
ProgressSet( 80, "80  percent")
FileSetAttrib($SD & "*.ini", "+H")

ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()

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