Doxie Posted June 30, 2004 Share Posted June 30, 2004 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 More sharing options...
Proof Posted June 30, 2004 Share Posted June 30, 2004 (edited) 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")? [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 June 30, 2004 by Proof Link to comment Share on other sites More sharing options...
Doxie Posted June 30, 2004 Author Share Posted June 30, 2004 Thanks for the input, i did not really get what you mean, but it was nice anyway 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 More sharing options...
Proof Posted June 30, 2004 Share Posted June 30, 2004 Then couldn't you simply update your progress bar after each operation ?!? Start and Close it, where you have mentioned. And between update the bar via ProgressSet ?! Link to comment Share on other sites More sharing options...
Doxie Posted June 30, 2004 Author Share Posted June 30, 2004 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 ******* expandcollapse popupFunc 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 More sharing options...
tuape Posted June 30, 2004 Share Posted June 30, 2004 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 More sharing options...
Doxie Posted June 30, 2004 Author Share Posted June 30, 2004 Thanks mate, it works perfectly, i had to be tired when i asked above, since it was so simple... Were ever i lay my script is my home... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now