SpookMeister Posted March 27, 2009 Share Posted March 27, 2009 (edited) It is fairly self explanatory, but basically I'm just making the script write and execute a second script that is just a progress bar, then providing a method of killing that second script when you are done. I guess you could also call it a "bailing wire and duct tape" form of multi-threading expandcollapse popup; When you want to notify the user that your main script will be busy for a while _StartProgress("Sending Email...") ; Put whatever comment you want ; Here I am just simulating your main program still running while the progress bar does its thing $timer = TimerInit() $seconds = 25 While TimerDiff($timer) / 1000 < $seconds Sleep(100) ToolTip("Main program running for " & Int(TimerDiff($timer) / 1000) & " seconds") WEnd ; When you want to get rid of the progress bar _StopProgress() ; ------------------------------------------------------------ ; stick the following code at the end of your script somewhere ; ------------------------------------------------------------ Func _StartProgress($s_comment = "Please Stand By") $s_path = @ScriptDir & "\progress.au3" $h_file = FileOpen($s_path, 2) $s_code = 'AutoItSetOption ("TrayIconHide",1)' & @CRLF & _ 'AutoItWinSetTitle("MyProgressBar")' & @CRLF & _ 'Dim $percent = 0' & @CRLF & _ 'ProgressOn("In Progress...", "' & $s_comment & '")' & @CRLF & _ 'While ProcessExists(' & @AutoItPID & ')' & @CRLF & _ 'ProgressSet($percent)' & @CRLF & _ '$percent += 5' & @CRLF & _ 'If $percent > 100 Then $percent = 0' & @CRLF & _ 'Sleep(500)' & @CRLF & _ 'WEnd' & @CRLF FileWrite($h_file, $s_code) FileClose($h_file) Run(@AutoItExe & " /AutoIt3ExecuteScript progress.au3", @ScriptDir) EndFunc ;==>_StartProgress Func _StopProgress() If WinExists("MyProgressBar") Then WinKill("MyProgressBar") FileDelete(@ScriptDir & "\progress.au3") EndFunc ;==>_StopProgress The progress bar just continues to go from 0% to 100% until you tell it to stop. Click on the attachment to see what the progress bar looks like Edited March 27, 2009 by SpookMeister [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
SpookMeister Posted March 27, 2009 Author Share Posted March 27, 2009 Edited initial code to make sure the progress bar quits if the main program dies before it can call the _StopProgress() function [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted March 29, 2009 Share Posted March 29, 2009 Thanks Spookmeister Best regards, EMiel Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
rajeshontheweb Posted April 7, 2009 Share Posted April 7, 2009 Hi there, when i used this piece of code, i had added a code to the main program Func OnAutoItExit ( ) _StopProgress() EndFunc This is just in case there was an unforeseen error in the script and it terminates abruptly before the stop progress was actually called :-) Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet 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