CluM09 Posted January 23, 2009 Posted January 23, 2009 Hello, I am new to AutoIt script. I need help with creating a progress bar that will: 1. Have a certain X and Y form dimension. 2. Has three labels that will accept string variables on top of the progress control which can change dymanically during the progress bar is advancing. 3. Has a Cancel button at the bottom of the progress bar control to allow cancelling the action. I like to have this script to be able to accept 4 arguments from the command line, one is for the total value of the maximum number of total progress and other three are for the three string variables I mentioned above. I hope to compile this script to .exe and use it with my other scripts. Is it possible to create an AutoIt script as I described? I go a sample script below which I played with, but I seem to get much futher. Thanks in advance. #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Sample Progress Bar", 421, 125) $Progress1 = GUICtrlCreateProgress(25, 25, 350, 20) $Button1 = GUICtrlCreateButton("OK", 400, 350) GUISetState(@SW_SHOW) For $i = 1 to 100 GUICtrlSetData($Progress1, $i) Sleep(50) Next Do Until GUIGetMsg() = $GUI_EVENT_CLOSE
FireFox Posted January 23, 2009 Posted January 23, 2009 @CluM09 Welcome to autoit forum Search in helpfile (F1 in SciTE) or on the forum... $w = 100 $h = 20 GuiCtrlCreateProgress(5, 5, $w, $h) For the rest, search for While Cheers, FireFox.
MyName Posted January 24, 2009 Posted January 24, 2009 Read in help file user this sample code UserExe Name1 Name2 Name3 500 include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> Dim $MaxProc $Form1 = GUICreate("Sample Progress Bar", 421, 125) $Progress1 = GUICtrlCreateProgress(25, 25, 350, 20) $Button1 = GUICtrlCreateButton("OK", 400, 350) $Label1 = GuiCtrlCreateLabel("Label 1",10,64,150,20) $Label2 = GuiCtrlCreateLabel("Label 2", 10,84,150,20) $Label3 = GuiCtrlCreateLabel("Label 3",10,104,150,20) GUISetState(@SW_SHOW) if $CmdLine[0] > 0 then GUICtrlSetData($Label1, $CmdLine[1]) GUICtrlSetData($Label2, $CmdLine[2]) GUICtrlSetData($Label3, $CmdLine[3]) $MaxProc = $CmdLine[4] Else $MaxProc = 100 endif For $i = 1 to $MaxProc GUICtrlSetData($Progress1, $i) Sleep(50) Next Do Until GUIGetMsg() = $GUI_EVENT_CLOSE -= [font="Verdana"]A Men Who believes in himself and not circumstances is the real Winner =-[/font]
CluM09 Posted January 26, 2009 Author Posted January 26, 2009 Thank you for the sample code for the progress bar. I tried your code, and it works, but it does not show the button on the form. I wanted to re-arrange the labels so that the labels will show on top of the progress bar, but they still show below the progress bar. How can I have the lablels show above the progress bar? Below is the code after I edited it. #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> Dim $MaxProc $Form1 = GUICreate("Sample Progress Bar", 420, 125) $Label1 = GUICtrlCreateLabel("Label 1", 20, 64, 150, 20) $Label2 = GUICtrlCreateLabel("Label 2", 20, 84, 150, 20) $Label3 = GUICtrlCreateLabel("Label 3", 20, 104, 150, 20) $Progress1 = GUICtrlCreateProgress(20, 20, 380, 20) $Button1 = GUICtrlCreateButton("Cancel", 400, 450) GUISetState(@SW_SHOW) If $CmdLine[0] > 0 Then GUICtrlSetData($Label1, $CmdLine[1]) GUICtrlSetData($Label2, $CmdLine[2]) GUICtrlSetData($Label3, $CmdLine[3]) $MaxProc = $CmdLine[4] Else $MaxProc = 100 EndIf For $i = 1 to $MaxProc $guiMsg = GUIGetMsg() If $guiMsg = $Button1 Then Exit GUICtrlSetData($Progress1, $i) Sleep(50) Next I two more questions. 1. How can I control the space height between the progress bar and the label? 2. Is there any way to have a fieldset drawn around outside the three labels or progress bar? Thanks again.
CluM09 Posted January 26, 2009 Author Posted January 26, 2009 Hello, I already figured it out. One thing I like to know is whether I can have the progress bar advance from right to left when it reahces its maximum value. Below is my code, but it does not reverse the progress direction as I think it should. Any idea how I can have the progress bar to reverse its direction when it reaches its maximum value? In other words, I like to have the progress to act like a ping-pong fashion. Thanks again. #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> Dim $MaxProc $Form1 = GUICreate("Sample Progress Bar", 420, 210) $descgroup = GUICtrlCreateGroup("Detail", 15, 10, 390, 100) $Label1 = GUICtrlCreateLabel("Label 1", 25, 30, 150, 20) $Label2 = GUICtrlCreateLabel("Label 2", 25, 55, 150, 20) $Label3 = GUICtrlCreateLabel("Label 3", 25, 80, 150, 20) $Progress1 = GUICtrlCreateProgress(15, 130, 390, 20) $Button1 = GUICtrlCreateButton("&Cancel", 185, 170, 65, 25) GUISetState(@SW_SHOW) If $CmdLine[0] > 0 Then GUICtrlSetData($Label1, $CmdLine[1]) GUICtrlSetData($Label2, $CmdLine[2]) GUICtrlSetData($Label3, $CmdLine[3]) $MaxProc = $CmdLine[4] Else $MaxProc = 100 EndIf Progress() Func Progress() For $i = 1 To $MaxProc If GUIGetMsg() = $Button1 Then Exit GUICtrlSetData($Progress1, $i) Sleep(50) If $i = 100 Then GUICtrlSetData($Progress1, "") For $i = 100 To 1 Step - 1 If GUIGetMsg() = $Button1 Then Exit GUICtrlSetState($Progress1, $i) Sleep(50) Next EndIf Next EndFunc
MyName Posted January 27, 2009 Posted January 27, 2009 i already told to you read in help file. OK since your are Newbie i will help you find out in 'C:\Program Files\AutoIt3\Examples\Helpfile\GUICtrlCreateProgress.au3' help file read this help help find use $progressbar2 in your code -= [font="Verdana"]A Men Who believes in himself and not circumstances is the real Winner =-[/font]
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