Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: thermometer
Note: For a simple status bar see the ShellOp Extender function aStatusBar.
This script simply displays a status bar on the screen when performing some Winbatch operation.
;######################################## ;########### Color Variables ############ ;######################################## DKBLUE ="0,0,128" BLUE ="0,0,255" LTGRAY ="192,192,192" GRAY ="128,128,128" DKGRAY ="64,64,64" GREEN ="0,255,0" RED ="255,0,0" BLACK ="0,0,0" WHITE ="255,255,255" YELLOW ="255,255,0" ;######################################## ;####### Headline Box Variables ######### ;######################################## rectNote = "100,30,900,270" rectNoteText = "70,200,950,800" rectnoteline1 = "0,0,1000,0" rectNoteline2 = "1000,1000,1000,0" rectNoteLine3 = "0,1000,1000,1000" rectNoteLine4 = "0,0,0,1000" notepenwidth = 20 rectnoteline1b = "40,150,960,150" rectNoteline2b = "960,840,960,150" rectNoteLine3b = "40,840,960,840" rectNoteLine4b = "40,150,40,840" notepenwidthb = 10 wbid = 2 Noteid = 4 DelayTime = 0.05 ;######################################## ;###### Creates the Main Window ######### ;######################################## BoxesUp("300,300,800,500",@Normal) BoxNew(1,"300,300,800,500",0) BoxCaption(1,"Update in Progress...Please Wait") BoxColor(1,LTGRAY,0) BoxDrawRect(1,"",2) ;######################################## ;######### Status Bar Outline ########### ;######################################## BoxPen(1,dkgray,10) boxdrawline(1,"103,545,900,545");top BoxPen(1,gray,10) boxdrawline(1,"103,535,900,535");top BoxPen(1,white,10) boxdrawline(1,"900,545,900,695");right BoxPen(1,ltgray,10) boxdrawline(1,"897,545,897,695");right BoxPen(1,ltgray,10) boxdrawline(1,"905,695,103,690");bottom BoxPen(1,white,10) boxdrawline(1,"900,700,100,700");bottom BoxPen(1,Black,10) boxdrawline(1,"103,545,103,690");left ;######################################## ;########## Set up the Loop ############ ;######################################## Index=50.0 ; Indicates the number of steps the status bar will take BoxDataTag(1,"Tagme") ; Just a box tag used for clearing the contents later ;Debug(@ON) For Begin=1.0 to Index by 1.0 BoxDataTag(1,"Loop") BoxColor(1,dkblue,0) Dist = int(100+((800*Begin)/Index)) BoxDrawRect(1,"104,554,%Dist%,696",2) BoxColor(1,white,0) BoxDrawRect(1,"%Dist%,554,898,696",2) BoxColor(1,LTGRAY,0) BoxTextFont(1,"Arial", 100,100,16) BoxTextColor(1, red) ;change the %% text color to red Completed = ((Begin/Index)*100) PercentComplete = Int( Completed ) TimeDelay (DelayTime) BoxDrawText(1,"100,200,896,500","%PercentComplete%%% complete",1,21) BoxTextColor(1, Black) ; change the text color for the status back to black ; Here I decided to put some CASE statements in because I will want to do something while ; the Status bar is drawing itself...(or else why would we want it?) So Here, you can insert ; Lines (or groups) of code to execute while the For-Next is Looping. I broke up the Case(s) into ; Steps of 10 because it would be easy to insert something later if we needed to. Another good idea ; for debugging is to insert a BoxDrawText() into each Case statement that tells what you are doing. ; If you do this, though, be sure to put a TimeDelay(1 or so) to let yourself read it before the next ; number is drawn. Be sure to keep your CASE integers less than the Index Number or else it will never ; execute. Select int(Begin) ; Select will ONLY accept integers, so we must convert Begin to an integer. Case 10 BoxTextFont(1,"Arial", 100,70,16) BoxDrawText(1,"50,50,600,200","Copying Explorer.exe",1,21) ; Insert Step 1 code here Break Case 20 BoxTextFont(1,"Arial", 100,70,16) BoxDrawText(1,"50,50,600,200","Copying Sol.exe",1,21) ; Insert Step 2 Code here Break Case 30 BoxTextFont(1,"Arial", 100,70,16) BoxDrawText(1,"50,50,600,200","Copying Netscape.exe",1,21) ; Insert Step 3 Code here Break Case 40 BoxTextFont(1,"Arial", 100,70,16) BoxDrawText(1,"50,50,600,200","Copying all Required .dll's ",1,21) ; Insert Step 4 Code here Break Case 50 BoxTextFont(1,"Arial", 100,70,16) BoxDrawText(1,"50,50,600,200","Completed Copying...Updating Registry",1,21) TimeDelay(2) BoxDrawText(1,"50,50,600,200","DONE!",1,21) ; Insert Step 5 Code here Break ; Insert any more code up to Index that you wish to insert. EndSelect BoxDataClear(1,"Loop") next BoxDataClear(1,"Tagme") BoxShut() Exit
Article ID: W14349
Filename: Another Progress Bar Example.txt
File Created: 2001:01:03:09:12:40
Last Updated: 2001:01:03:09:12:40