MadBoy Posted January 21, 2006 Share Posted January 21, 2006 Hey, i've been reading a lot of posts about progress bars but since my coding knowledge is poor it takes me a lot of time to figure how to add progress bar made by elltoro in this post. Maybe someone could hel me out by adding it to my code so i could understand it ;p and so we could see the progress bar going while the applications are being installed by the end user (hopefully it would be more or less accurate).Here's the progress bar: expandcollapse popupopt("MustDeclareVars", 1) opt("GUICoordMode", 2) #include-once #include <GUIConstants.au3> #Include <GuiStatusBar.au3> Local $gui, $StatusBar1, $Progress1, $msg, $asize[1],$iProgress Local $a[3] = [100,350,-1] Local $s[3] = ["New Text","More Text","Even More Text"] ; Statusbar with progress bar $gui = GUICreate("StatusBar GUI", 500, -1, -1, -1, $WS_SIZEBOX) GUISetState(@SW_SHOW) Dim $s[3] = ["Ready. ","","Even More Text"],$a_box $StatusBar1 = _GuiCtrlStatusBarCreate($gui, $a, $s) ;=== add progress to statusbar ;Get panel size and shink a little for progressbar size. $a_box = _SizePanel($StatusBar1,1) ;Create the progress bar with the proper size. $Progress1 = GUICtrlCreateProgress($a_box[0],$a_box[1],$a_box[2],$a_box[3]) GUICtrlSetResizing($Progress1,802) ;change progressbars parent to statusbar _SetParent($Progress1,$StatusBar1) ; move progressbar to statusbar. _CtrlMove($Progress1,$a_box) ; and ta da working GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_RESIZED ;_ResizeHandler();needed to handle child???? _GuiCtrlStatusBarResize ($StatusBar1) Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else if $iProgress < 100 Then $iProgress = $iProgress +1 GUICtrlSetData($Progress1,$iProgress) Else $iProgress = 0 EndIf sleep(100) ;;;;; EndSelect WEnd Exit ;=============================================================================== ;Resize things here not handled by GuiCtrlSetResize ;=============================================================================== Func _ResizeHandler() _GuiCtrlStatusBarResize ($StatusBar1) ; _CtrlMove($Progress1,_SizePanel($StatusBar1,1)) EndFunc;==>_ResizeHandler ;=============================================================================== ;GetPanel size and shrink them for progress size. ;=============================================================================== Func _SizePanel($id_control,$i_panel,$i_pad =2) Local $a_box = _GuiCtrlStatusBarGetRect($id_control,$i_panel) ;shrink the rect a little to fit inside panel $a_box[2] = $a_box[2]- $a_box[0]-$i_pad $a_box[3] = $a_box[3]- $a_box[1]-$i_pad $a_box[0] = $a_box[0] +$i_pad $a_box[1] = $a_box[1] +$i_pad Return $a_box EndFunc ;=============================================================================== ;Wrap SetParent Msg ;=============================================================================== Func _SetParent($id_child, $h_parent) ; Local $h_parent,$h_child If Not IsHWnd($h_parent) Then $h_parent = HWnd($h_parent) If Not IsHWnd($id_child) Then $id_child = GUICtrlGetHandle($id_child) If DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $id_child, "hwnd", $h_parent) <> 0 Then Return Else seterror(1) Return 0 EndIf EndFunc ;==>_SetParent ;=============================================================================== ;Wrap MoveWindow Msg ;=============================================================================== Func _CtrlMove($id_control,$a_metric,$b_repaint =True) Local $h_control If Not IsHWnd($id_control) Then $h_control = GUICtrlGetHandle($id_control) if IsArray($a_metric) Then if DllCall("user32.dll", "long", "MoveWindow", "hwnd", $h_control, _ "int", $a_metric[0], "int", $a_metric[1], _ "int", $a_metric[2], "int", $a_metric[3], "int",$b_repaint) <> 0 Then Return Else seterror(1) Return 0 EndIf Else seterror(1) Return 0 EndIf EndFuncAnd here is my code: expandcollapse popup; Installer #NoTrayIcon ; Dane programu $autor = "Me / Company" ; Wersja;) $version = 0.8 ; Lokalizacja - Nazwa serwera $location = "\\server\Install" #include <GUIConstants.au3> ;FileInstall("c:\logo.gif", "C:\Windows\Temp.gif") Opt("GUICoordMode", 1) GUICreate("Installer ver. " & $version, 600,460) ; Logo ;$n=GUICtrlCreatePic("c:\Windows\Temp.gif",0,0, $position2 + 75,35) ; TAG - program napisany przez $position10 = 310 $position11 = 10 $label50 = GUICtrlCreateLabel ("", $position10, $position11, 300, 15) GUICtrlSetData( $Label50, "Program napisał: " & $autor,$GUI_SHOW ) GUICtrlSetState(-1,$GUI_DISABLE) $tab=GUICtrlCreateTab (10,5, 585,450) ; OPROGRAMOWANIE - MENU $tab0=GUICtrlCreateTabitem ( "Programy") ; Grupa pierwsza - profile $nr0 = 14; pierwsza wspolrzedna kontrolek $nr1 = 17; pierwsza wspolrzedna dla guzikow radio tabelki $nr2 = 70; druga wspolrzedna dla guzikow radio tabelki $nr3 = 16; $position1 = 19 $position2 = 300 $nr_button1 = 450 $nr_button2 = 400 ; Utworzenie kontrolek $button_1 = GUICtrlCreateButton ("Zainstaluj", $nr_button1, $nr_button2, 120, 40) $group_1 = GUICtrlCreateGroup ("Wybierz profil:", $nr0, 50, 175, 220) GUIStartGroup() $radio_1 = GUICtrlCreateRadio ("Standardowy", $nr1, $nr2, 150, 20) $radio_2 = GUICtrlCreateRadio ("Standardowy mobilny", $nr1, $nr2 + 30, 150, 20) $radio_3 = GUICtrlCreateRadio ("Zaawansowany", $nr1, $nr2 + 60, 150, 20) $radio_4 = GUICtrlCreateRadio ("Zaawansowany mobilny", $nr1, $nr2 + 90, 150, 20) $radio_5 = GUICtrlCreateRadio ("Super", $nr1, $nr2 +120, 150, 20) $radio_6 = GUICtrlCreateRadio ("Super mobilny", $nr1, $nr2 + 150, 150, 20) ; Grupa druga - wybor reczny $group_2 = GUICtrlCreateGroup ("", 200, 50, 175, 35) $radio_7 = GUICtrlCreateRadio ("Wybór reczny", 202, 60, 150, 20) ;GUICtrlSetState(-1,$GUI_DISABLE) ;Napisy do GUI wyswietlanego po wybraniu profilu $group_3 = GUICtrlCreateGroup ("", $nr0, 280, 175, 165) GUICtrlSetState(-1,$GUI_HIDE) $Label1= GUICtrlCreateLabel ("", $position1, $position2, 150, 20) $Label2= GUICtrlCreateLabel ("", $position1, $position2 + 15, 150, 20) $Label3= GUICtrlCreateLabel ("", $position1, $position2 + 30, 150, 20) $Label4= GUICtrlCreateLabel ("", $position1, $position2 + 45, 150, 20) $Label5= GUICtrlCreateLabel ("", $position1, $position2 + 60, 150, 20) $Label6= GUICtrlCreateLabel ("", $position1, $position2 + 75, 150, 20) $Label7= GUICtrlCreateLabel ("", $position1, $position2 + 90, 150, 20) $Label8= GUICtrlCreateLabel ("", $position1, $position2 + 105, 150, 20) $Label9= GUICtrlCreateLabel ("", $position1, $position2 + 120, 150, 20) ;GUI z CheckBox-ami dla wyboru recznego $wybor= GUICtrlCreateTreeView (200,90,175,180,BitOr($TVS_CHECKBOXES,$TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE) GUICtrlSetState(-1,$GUI_HIDE) $label10 = GuiCtrlCreateTreeViewItem("7 zip", $wybor) $label11 = GuiCtrlCreateTreeViewItem("Adobe Acrobat 7.0", $wybor) $label12 = GuiCtrlCreateTreeViewItem("Cisco VPN 4.7", $wybor) $label13 = GuiCtrlCreateTreeViewItem("Lotus Notes 5.02c", $wybor) $label14 = GuiCtrlCreateTreeViewItem("Lotus Notes 5.10a", $wybor) $label15 = GuiCtrlCreateTreeViewItem("Microsoft Office XP", $wybor) $label16 = GuiCtrlCreateTreeViewItem("Microsoft Office 2003", $wybor) $label17 = GuiCtrlCreateTreeViewItem("Microsoft Project 2003", $wybor) $label18 = GuiCtrlCreateTreeViewItem("Microsoft Visio 2003", $wybor) $label19 = GuiCtrlCreateTreeViewItem("Symantec Antivirus", $wybor) ; STEROWNIKI MENU $tab1=GUICtrlCreateTabitem ("Sterowniki") $button_2 = GUICtrlCreateButton ("Wyszukaj sterowniki", $nr_button1, $nr_button2, 120, 40) $treeview = GUICtrlCreateTreeView ($nr0,50,300,350,BitOr($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE) ;---- $maxdataitem = GUICtrlCreateTreeViewitem ("Maxdata",$treeview) $3100Xitem = GUICtrlCreateTreeViewitem ("Maxdata 3100X",$maxdataitem) $3150Xitem = GUICtrlCreateTreeViewitem ("Maxdata 3100X",$maxdataitem) $3200Xitem = GUICtrlCreateTreeViewitem ("Maxdata 3200X",$maxdataitem) $6100Xitem = GUICtrlCreateTreeViewitem ("Maxdata 6100X",$maxdataitem) $7000Xitem = GUICtrlCreateTreeViewitem ("Maxdata 7000X",$maxdataitem) $7000DXitem = GUICtrlCreateTreeViewitem ("Maxdata 7000X",$maxdataitem) $7100Xitem = GUICtrlCreateTreeViewitem ("Maxdata 7100X",$maxdataitem) $8000Xitem = GUICtrlCreateTreeViewitem ("Maxdata 8000X",$maxdataitem) $8100ISitem = GUICtrlCreateTreeViewitem ("Maxdata 8100IS",$maxdataitem) $8100Xitem = GUICtrlCreateTreeViewitem ("Maxdata 8100X",$maxdataitem) ;---- $compaqitem = GUICtrlCreateTreeViewitem ("HP Compaq",$treeview) $evon150item = GUICtrlCreateTreeViewitem ("Compaq EVO N150",$compaqitem) $evon160item = GUICtrlCreateTreeViewitem ("Compaq EVO N160",$compaqitem) ;---- $fujitsuitem = GUICtrlCreateTreeViewitem ("Fujitsu-Siemens",$treeview) $fujitsuP300SiSitem = GUICtrlCreateTreeViewitem ("Fujitsu-Siemens P300 - SiS661",$fujitsuitem) $fujitsuP320SiSitem = GUICtrlCreateTreeViewitem ("Fujitsu-Siemens P320 - SiS661",$fujitsuitem) ;---- $toshibaitem = GUICtrlCreateTreeViewitem ("Toshiba",$treeview) ;--- $ibmitem = GUICtrlCreateTreeViewitem ("Ibm",$treeview) ;GUICtrlCreateTabitem ("") ; Show the GUI GUISetState () ;----------------------------------------------------------------------------- ;----------------------------------------------------------------------------- ;----------------------------------------------------------------------------- ;----------------------------------------------------------------------------- ;----------------------------------------------------------------------------- ; Sciezki do programow $7zip = $location &"\Main\Zip\zip.exe /S" $7zip_comment = "7zip" $Adobe7 = $location &"\Main\Adobe_Acrobat\Adobe_Reader_7.0.msi -qn" $Adobe7_comment = "Adobe Acrobat Reader 7.0" $Notes502 = $location &"\Main\Lotus_Notes_5.02c\Setup.exe -s -f1 SETUP.ISS" $Notes502_comment = "Lotus Notes 5.02c" $Notes510 = $location &"\Main\Lotus_Notes_5.10a\Setup.exe -s -f1 SETUP.ISS" $Notes510_comment = "Lotus Notes 5.10a" $Main = $location &"\Files\Main.bat" $Main_comment = "Windows - Personalizacja" $OfficeXP = $location &"\Main\Microsoft_OfficeXP\setup.exe TRANSFORMS=Unattended.MST /qb-" $OfficeXP_comment = "Microsoft Office XP" $Office2003 = $location &"\Advanced\Microsoft_Office2003\setup.exe TRANSFORMS=Unattended.MST /qb-" $Office2003_comment = "Microsoft Office 2003" $Project2003 = $location &"\Advanced\Microsoft_Project2003\setup.exe TRANSFORMS=Unattended.MST /qb-" $Project2003_comment = "Microsoft Project 2003" $Symantec = $location &"\Main\Symantec_Antivirus\Symantec_AntiVirus.msi /qn RUNLIVEUPDATE=0 REBOOT=REALLYSUPPRESS" $Symantec_comment = "Symantec Antivirus 10" $Visio2003 = $location &"\Advanced\Microsoft_Visio2003\setup.exe TRANSFORMS=Unattended.MST /qb-" $Visio2003_comment = "Microsoft Visio 2003" $Vpn = $location &"\Main\Cisco_VPN\setup.exe" $Vpn_comment = "Vpn Client 4.7" While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE FileRecycle ("C:\Windows\Temp.gif") Exit Case $msg = $radio_1 GUICtrlSetState($group_3, $GUI_SHOW) GUICtrlSetData($group_3, "Do zainstalowania:") GUICtrlSetData( $Label1, $7zip_comment) GUICtrlSetData( $Label2, $Adobe7_comment) GUICtrlSetData( $Label3, $Notes502_comment) GUICtrlSetData( $Label4, $OfficeXP_comment) GUICtrlSetData( $Label5, $Symantec_comment) GUICtrlSetData( $Label6, $Main_comment) GUICtrlSetData( $Label7, "") GUICtrlSetData( $Label8, "") GUICtrlSetData( $Label9, "") Case $msg = $radio_2 GUICtrlSetState($group_3, $GUI_SHOW) GUICtrlSetData($group_3, "Do zainstalowania:") GUICtrlSetData( $Label1, $7zip_comment) GUICtrlSetData( $Label2, $Adobe7_comment) GUICtrlSetData( $Label3, $Notes502_comment) GUICtrlSetData( $Label4, $OfficeXP_comment) GUICtrlSetData( $Label5, $Symantec_comment) GUICtrlSetData( $Label6, $Main_comment) GUICtrlSetData( $Label7, $Vpn_comment) GUICtrlSetData( $Label8, "") GUICtrlSetData( $Label9, "") Case $msg = $radio_3 GUICtrlSetState($group_3, $GUI_SHOW) GUICtrlSetData($group_3, "Do zainstalowania:") GUICtrlSetData( $Label1, $7zip_comment) GUICtrlSetData( $Label2, $Adobe7_comment) GUICtrlSetData( $Label3, $Notes510_comment) GUICtrlSetData( $Label4, $Office2003_comment) GUICtrlSetData( $Label5, $Symantec_comment) GUICtrlSetData( $Label6, $Main_comment) GUICtrlSetData( $Label7, "") GUICtrlSetData( $Label8, "") GUICtrlSetData( $Label9, "") Case $msg = $radio_4 GUICtrlSetState($group_3, $GUI_SHOW) GUICtrlSetData($group_3, "Do zainstalowania:") GUICtrlSetData( $Label1, $7zip_comment) GUICtrlSetData( $Label2, $Adobe7_comment) GUICtrlSetData( $Label3, $Notes510_comment) GUICtrlSetData( $Label4, $Office2003_comment) GUICtrlSetData( $Label5, $Symantec_comment) GUICtrlSetData( $Label6, $Main_comment) GUICtrlSetData( $Label7, $Vpn_comment) GUICtrlSetData( $Label8, "") GUICtrlSetData( $Label9, "") Case $msg = $radio_5 GUICtrlSetState($group_3, $GUI_SHOW) GUICtrlSetData($group_3, "Do zainstalowania:") GUICtrlSetData( $Label1, $7zip_comment) GUICtrlSetData( $Label2, $Adobe7_comment) GUICtrlSetData( $Label3, $Notes510_comment) GUICtrlSetData( $Label4, $Office2003_comment) GUICtrlSetData( $Label5, $Project2003_comment) GUICtrlSetData( $Label6, $Visio2003_comment) GUICtrlSetData( $Label7, $Symantec_comment) GUICtrlSetData( $Label8, $Main_comment) GUICtrlSetData( $Label9, "") Case $msg = $radio_6 GUICtrlSetState($group_3, $GUI_SHOW) GUICtrlSetData($group_3, "Do zainstalowania:") GUICtrlSetData( $Label1, $7zip_comment) GUICtrlSetData( $Label2, $Adobe7_comment) GUICtrlSetData( $Label3, $Notes510_comment) GUICtrlSetData( $Label4, $Office2003_comment) GUICtrlSetData( $Label5, $Project2003_comment) GUICtrlSetData( $Label6, $Visio2003_comment) GUICtrlSetData( $Label7, $Symantec_comment) GUICtrlSetData( $Label8, $Main_comment) GUICtrlSetData( $Label9, $Vpn_comment) Case $msg = $button_1 AND BitAnd(GUICtrlRead($radio_1),$GUI_CHECKED) = $GUI_CHECKED RunWait($7zip, "") RunWait(@ComSpec & " /c " & $Adobe7, "", @SW_HIDE) RunWait($Notes502, "") RunWait($OfficeXP, "") RunWait(@ComSpec & " /c " & $Symantec, "", @SW_HIDE) RunWait($Main, "") Exit Case $msg = $button_1 AND BitAnd(GUICtrlRead($radio_2),$GUI_CHECKED) = $GUI_CHECKED RunWait($7zip, "") RunWait(@ComSpec & " /c " & $Adobe7, "", @SW_HIDE) RunWait($Notes502, "") RunWait($OfficeXP, "") RunWait(@ComSpec & " /c " & $Symantec, "", @SW_HIDE) RunWait($Vpn, "") RunWait($Main, "") Exit Case $msg = $button_1 AND BitAnd(GUICtrlRead($radio_3),$GUI_CHECKED) = $GUI_CHECKED RunWait($7zip, "") RunWait(@ComSpec & " /c " & $Adobe7, "", @SW_HIDE) RunWait($Notes510, "") RunWait($Office2003, "") RunWait(@ComSpec & " /c " & $Symantec, "", @SW_HIDE) RunWait($Main, "") Exit Case $msg = $button_1 AND BitAnd(GUICtrlRead($radio_4),$GUI_CHECKED) = $GUI_CHECKED RunWait($7zip, "") RunWait(@ComSpec & " /c " & $Adobe7, "", @SW_HIDE) RunWait($Notes510, "") RunWait($Office2003, "") RunWait(@ComSpec & " /c " & $Symantec, "", @SW_HIDE) RunWait($Vpn, "") RunWait($Main, "") Exit Case $msg = $button_1 AND BitAnd(GUICtrlRead($radio_5),$GUI_CHECKED) = $GUI_CHECKED RunWait($7zip, "") RunWait(@ComSpec & " /c " & $Adobe7, "", @SW_HIDE) RunWait($Notes510, "") RunWait($Office2003, "") RunWait($Project2003, "") RunWait($Visio2003, "") RunWait(@ComSpec & " /c " & $Symantec, "", @SW_HIDE) RunWait($Main, "") Exit Case $msg = $button_1 AND BitAnd(GUICtrlRead($radio_6),$GUI_CHECKED) = $GUI_CHECKED RunWait($7zip, "") RunWait(@ComSpec & " /c " & $Adobe7, "", @SW_HIDE) RunWait($Notes510, "") RunWait($Office2003, "") RunWait($Project2003, "") RunWait($Visio2003, "") RunWait(@ComSpec & " /c " & $Symantec, "", @SW_HIDE) RunWait($Vpn, "") RunWait($Main, "") Exit Case $msg = $radio_7 GUICtrlSetState($wybor, $GUI_SHOW) EndSelect WEndI'm sure i have to add it somewhere in Case $msg = $button_1 AND BitAnd(GUICtrlRead($radio_1),$GUI_CHECKED) = $GUI_CHECKEDbut i don't realy have a clue how to do it.Muchos tnx to any help My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
MadBoy Posted January 22, 2006 Author Share Posted January 22, 2006 Hehe, my questions seems always either too hard or just unclear. Would be nice if someone tell me what i'm doing wrong that posts like this aren't taken into consideration for help ;p If someone would just 'show me' the way i'll try going it but having no responses at all makes me wonder it's realy hard to add progress bar to my app ;p Maybe just polish comments should be in english. Just lemme know how i could fix my post so it would be easier for you guys to try to help me With Regards, My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
peter1234 Posted January 22, 2006 Share Posted January 22, 2006 Here is an example ;progress bar example #include <GUIConstants.au3> $GUI1=GUICreate(" Progress Bar",600,200,-1, -1, -1) GUISetState () $progressbar1 = GUICtrlCreateProgress (120,125,455,20,$PBS_SMOOTH) GUICtrlSetColor(-1,8421504) $i_stop= 1000 For $i_Loop = 1 to $i_stop $p=100*$i_Loop/$i_stop GUICtrlSetData ($progressbar1,$p) sleep(2) Next While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Link to comment Share on other sites More sharing options...
ChrisL Posted January 22, 2006 Share Posted January 22, 2006 Hehe, my questions seems always either too hard or just unclear. Would be nice if someone tell me what i'm doing wrong that posts like this aren't taken into consideration for help ;p If someone would just 'show me' the way i'll try going it but having no responses at all makes me wonder it's realy hard to add progress bar to my app ;p Maybe just polish comments should be in english. Just lemme know how i could fix my post so it would be easier for you guys to try to help me With Regards,You are installing a set of programs based on a user choice, Yes?I don't really see how you can run a progress during the installation of individual programs because I can't think of anyway you would know how long each installer would take or where exactly it is in the installation.You could have a progress bar which moves up after each part is installed.You would need to create a progress bar, ProgressOn() then after each application install is completed you devide the number of completed applications by the amount of total applications to install x 100, this would give you the completed percentage. Then use ProgressSet() to set the new percentage. [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
MadBoy Posted January 23, 2006 Author Share Posted January 23, 2006 You are installing a set of programs based on a user choice, Yes?I don't really see how you can run a progress during the installation of individual programs because I can't think of anyway you would know how long each installer would take or where exactly it is in the installation.You could have a progress bar which moves up after each part is installed.You would need to create a progress bar, ProgressOn() then after each application install is completed you devide the number of completed applications by the amount of total applications to install x 100, this would give you the completed percentage. Then use ProgressSet() to set the new percentage.There are few options there to install new software. First is too choose one of the profiles (depends on the user if he has laptop or not, if he is director or just normal user) and there is also choice menu where you can choose what you want to be installed (it's not yet started so this isn't the issue ;p). And Yes i would like the progress bar to move every part is installed. peter1234 - i know there are lots and lots of progress bar examples, problem is i don't realy know how to add them into my script Well anyways i'll try to play with my script today and add it My little company: Evotec (PL version: Evotec) 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