dreamzboy Posted June 29, 2007 Posted June 29, 2007 I read and read and read, and I became retarded. I dunno how to get the progress bar to work. Please save me from driving myself insane. Much thanks! #include <GuiConstants.au3> Opt ("TrayIconDebug", 1) GuiCreate("", 361, 110,-1, -1) $Calisto = "Calisto MT" $Progress_1 = GuiCtrlCreateProgress(10, 40, 340, 20) GUICtrlSetColor (-1, 0x4169e1) $Label_2 = GuiCtrlCreateLabel("Loading next program, please wait.", 10, 10, 300, 20) GUICtrlSetFont (-1, 11, 500, 0, $Calisto) $button = GUICtrlCreateButton ("Cancel", 145, 70, 50, 30) GuiSetState() ;$count = 0 Do For $i = 0 To 100 Step 10 $msg = GUIGetMsg () If $msg = $button Then ExitLoop Else GUICtrlSetData ($Progress_1, $i) Sleep (1000) EndIf Next Until $msg = $GUI_EVENT_CLOSE In case you're totally confused by this advance coding technique, I'm trying to get the "cancel" button to work.
Shyke Posted June 29, 2007 Posted June 29, 2007 (edited) #include <GuiConstants.au3> Opt ("TrayIconDebug", 1) GuiCreate("", 361, 110,-1, -1) $Calisto = "Calisto MT" $Progress_1 = GuiCtrlCreateProgress(10, 40, 340, 20) GUICtrlSetColor (-1, 0x4169e1) $Label_2 = GuiCtrlCreateLabel("Loading next program, please wait.", 10, 10, 300, 20) GUICtrlSetFont (-1, 11, 500, 0, $Calisto) $button = GUICtrlCreateButton ("Cancel", 145, 70, 50, 30) GuiSetState() ;$count = 0 $doonce = 0 Do $msg = GUIGetMsg () If $msg = $button Then ExitLoop If $doonce = 0 Then For $i = 0 To 100 Step 10 GUICtrlSetData ($Progress_1, $i) Sleep (1000) Next $doonce = 1 EndIf Until $msg = $GUI_EVENT_CLOSE Is something like that sufficient? Edited June 29, 2007 by Shyke
PsaltyDS Posted June 29, 2007 Posted June 29, 2007 (edited) This makes your message loop work without the long sleep causing button hits to be missed: expandcollapse popup#include <GuiConstants.au3> Opt("TrayIconDebug", 1) GUICreate("", 361, 110, -1, -1) $Calisto = "Calisto MT" $Progress_1 = GUICtrlCreateProgress(10, 40, 340, 20) GUICtrlSetColor(-1, 0x4169e1) $Label_2 = GUICtrlCreateLabel("Loading next program, please wait.", 10, 10, 300, 20) GUICtrlSetFont(-1, 11, 500, 0, $Calisto) $button = GUICtrlCreateButton("Cancel", 145, 70, 50, 30) GUISetState() Dim $Timer = TimerInit(), $i = 0 Do $msg = GUIGetMsg() If $msg = $button Then ExitLoop If TimerDiff($Timer) = 1000 Then $i += 1 GUICtrlSetData($Progress_1, $i) $Timer = TimerInit() EndIf Until $i = 100oÝ÷ ØÆ²mê~Ú)ÉÉ·§¢ÒæyÖ©®+zËj»ajÛ&¢a'!jx±Ê%¢»²+`¡ë¶ëvÚyÊyÖ¬heë,j¥¢[ºÒ.¥ÖyØ~Þ½éí^jëh×6#include <GuiConstants.au3> ; Thanks to gafrost for the following tweak: DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) Opt("GuiOnEventMode", 1) $hGUI = GUICreate("Progress Bar Test", 300, 130) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") $ProgBar_1 = GUICtrlCreateProgress(10, 10, 280, 30, $PBS_Smooth) $UpButton = GUICtrlCreateButton("UP", 15, 50, 76, 40) GUICtrlSetOnEvent(-1, "_ButtonHit") $DownButton = GUICtrlCreateButton("Down", 112, 50, 76, 40) GUICtrlSetOnEvent(-1, "_ButtonHit") $StopButton = GUICtrlCreateButton("STOP", 209, 50, 76, 40) GUICtrlSetOnEvent(-1, "_ButtonHit") $Label_1 = GUICtrlCreateLabel("Red = 0, Green = 0, Blue = 0, Color = 0xFF0000", 10, 100, 280, 20, $SS_Center) GUISetState() Global $Progress = 0 ; Will be 0 thru 100 Global $Increment = 0 ; Controls direction of progress While 1 Sleep(100) _SetProgColor() WEnd Func _Quit() Exit EndFunc ;==>_Quit Func _ButtonHit() Local $CtrlID = @GUI_CtrlId Switch $CtrlID Case $UpButton $Increment = 1 Case $DownButton $Increment = -1 Case $StopButton $Increment = 0 EndSwitch EndFunc ;==>_ButtonHit Func _SetProgColor() If $Increment Then $Progress += $Increment If $Progress < 0 Then $Progress = 0 $Increment = 0 ElseIf $Progress > 100 Then $Progress = 100 $Increment = 0 EndIf GUICtrlSetData($ProgBar_1, $Progress) Local $Redness = Int(255 - ($Progress / 100 * 512)) If $Redness < 0 Then $Redness = 0 Local $Greeness = Int(($Progress / 100 * 512) - 257) If $Greeness < 0 Then $Greeness = 0 Local $Blueness = Int(255 - ($Redness + $Greeness)) Local $ProgColor = ($Redness * 256 * 256) + ($Greeness * 256) + $Blueness GUICtrlSetData($Label_1, "Red = " & $Redness & ", Green = " & $Greeness & ", Blue = " & $Blueness & ", Color = 0x" & Hex($ProgColor, 6)) GUICtrlSetColor($ProgBar_1, $ProgColor) EndIf EndFunc ;==>_SetProgColor If it doesn't help, ignore it... Edited June 29, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
dreamzboy Posted July 2, 2007 Author Posted July 2, 2007 PsaltyDS,Your Cancel button works, however, the progressbar doesn't move at all. Meaning the bar left blank and nothing is filled in. I assume the GuiCtrlSetData doesn't respond. Anyway, it's too complicated and I don't want further waste of brain cells. However, I do have one request. I couldn't get the progress bar to close after it reaches 100. I tested the function and it closes fine, but when I implement it along with my other codes, it doesn't respond. Please advice.#include <GuiConstants.au3> Opt("TrayIconDebug", 1) GUICreate("", 361, 110, -1, -1) $Calisto = "Calisto MT" $Progress_1 = GUICtrlCreateProgress(10, 40, 340, 20) GUICtrlSetColor(-1, 0x4169e1) $Label_2 = GUICtrlCreateLabel("Loading next program, please wait.", 10, 10, 300, 20) GUICtrlSetFont(-1, 11, 500, 0, $Calisto) $button = GUICtrlCreateButton("Cancel", 145, 70, 50, 30) GUISetState() Dim $Timer = TimerInit(), $i = 0 Do $msg = GUIGetMsg() If $msg = $button Then ExitLoop If TimerDiff($Timer) = 1000 Then $i += 1 GUICtrlSetData($Progress_1, $i) $Timer = TimerInit() EndIf Until $i = 100By the way, how come I couldn't get the Function to stand out like Do, Until, Dim, etc...in here, is there something special i have to do? It worked before, what happened?
Valuater Posted July 2, 2007 Posted July 2, 2007 #include <GuiConstants.au3> Opt("TrayIconDebug", 1) GUICreate("", 361, 110, -1, -1) $Calisto = "Calisto MT" $Progress_1 = GUICtrlCreateProgress(10, 40, 340, 20) GUICtrlSetColor(-1, 0x4169e1) $Label_2 = GUICtrlCreateLabel("Loading next program, please wait.", 10, 10, 300, 20) GUICtrlSetFont(-1, 11, 500, 0, $Calisto) $button = GUICtrlCreateButton("Cancel", 145, 70, 50, 30) GUISetState() Dim $Timer = TimerInit(), $i = 0 Do $msg = GUIGetMsg() If $msg = $button Then ExitLoop If TimerDiff($Timer) >= 1000 Then $i += 1 GUICtrlSetData($Progress_1, $i) $Timer = TimerInit() EndIf Until $i = 100 8)
dreamzboy Posted July 2, 2007 Author Posted July 2, 2007 Thanks a bunch. Still the progress bar would not close after the first program executed. Can you see why? I think this is my last question of the day expandcollapse popup#include <GuiConstants.au3> Opt ("TrayIconDebug", 1) GuiCreate ("MyGUI", 392, 323,-1, -1) $Checkbox_1 = GuiCtrlCreateCheckbox("Checkbox1", 20, 30, 100, 10) $Checkbox_2 = GuiCtrlCreateCheckbox("Checkbox2", 20, 60, 90, 20) $Checkbox_3 = GuiCtrlCreateCheckbox("Checkbox3", 20, 100, 90, 10) $Run = GUICtrlCreateButton ("Run", 20, 130, 50, 20) dim $check1 dim $check2 dim $check3 GuiSetState() getMsg() Func getMsg () Do $msg = GuiGetMsg() $check1 = GUICtrlRead ($Checkbox_1) $check2 = GUICtrlRead ($Checkbox_2) $check3 = GUICtrlRead ($Checkbox_3) Until $msg = $GUI_EVENT_CLOSE Or $msg = $Run If $msg = $GUI_EVENT_CLOSE Then Exit EndIf While $msg = 6 And $check1 = 4 And $check2 = 4 And $check3 = 4 MsgBox (0, "", "Please select a program to install.") getMsg () WEnd If $check1 = 1 Then function1 () If $check2 = 1 Or $check3 = 1 Then wait_progress () EndIf If $check2 = 1 Then function2 () If $check3 = 1 Then wait_progress () EndIf If $check3 = 1 Then function3 () getMsg () EndFunc Func function1 () MsgBox (0, "", "Running program 1", 2) EndFunc Func function2 () MsgBox (0, "", "Running program 2", 2) EndFunc Func function3 () MsgBox (0, "", "Running program 3", 2) EndFunc Func wait_progress () GUICreate("", 361, 110, -1, -1) $Calisto = "Calisto MT" $Progress_1 = GUICtrlCreateProgress(10, 40, 340, 20) GUICtrlSetColor(-1, 0x4169e1) $Label_2 = GUICtrlCreateLabel("Loading next program, please wait.", 10, 10, 300, 20) GUICtrlSetFont(-1, 11, 500, 0, $Calisto) $button = GUICtrlCreateButton("Cancel", 145, 70, 50, 30) Dim $Timer = TimerInit(), $i = 0 GUISetState () Do $msg = GUIGetMsg() If $msg = $button Then ExitLoop If TimerDiff($Timer) >= 1000 Then $i += 50 GUICtrlSetData($Progress_1, $i) $Timer = TimerInit() EndIf Until $i = 100 EndFunc
kp3 Posted July 2, 2007 Posted July 2, 2007 (edited) here u go... Acctualy i dont understand most of ur code but :/ I just added 4 things. I declared $progress_1. I added guictrlsetdata($progress_1,0) 1 time... expandcollapse popup#include <GuiConstants.au3> Opt ("TrayIconDebug", 1) GuiCreate ("MyGUI", 392, 323,-1, -1) $Checkbox_1 = GuiCtrlCreateCheckbox("Checkbox1", 20, 30, 100, 10) $Checkbox_2 = GuiCtrlCreateCheckbox("Checkbox2", 20, 60, 90, 20) $Checkbox_3 = GuiCtrlCreateCheckbox("Checkbox3", 20, 100, 90, 10) $Run = GUICtrlCreateButton ("Run", 20, 130, 50, 20) Dim $Progress_1 dim $check1 dim $check2 dim $check3 GuiSetState() getMsg() Func getMsg () Do $msg = GuiGetMsg() $check1 = GUICtrlRead ($Checkbox_1) $check2 = GUICtrlRead ($Checkbox_2) $check3 = GUICtrlRead ($Checkbox_3) Until $msg = $GUI_EVENT_CLOSE Or $msg = $Run If $msg = $GUI_EVENT_CLOSE Then Exit EndIf While $msg = 6 And $check1 = 4 And $check2 = 4 And $check3 = 4 MsgBox (0, "", "Please select a program to install.") getMsg () WEnd If $check1 = 1 Then function1 () If $check2 = 1 Or $check3 = 1 Then wait_progress () EndIf If $check2 = 1 Then function2 () If $check3 = 1 Then wait_progress () EndIf If $check3 = 1 Then function3 () getMsg () EndFunc Func function1 () MsgBox (0, "", "Running program 1", 2) EndFunc Func function2 () MsgBox (0, "", "Running program 2", 2) EndFunc Func function3 () MsgBox (0, "", "Running program 3", 2) EndFunc Func wait_progress () GUICreate("", 361, 110, -1, -1) $Calisto = "Calisto MT" $Progress_1 = GUICtrlCreateProgress(10, 40, 340, 20) GUICtrlSetColor(-1, 0x4169e1) $Label_2 = GUICtrlCreateLabel("Loading next program, please wait.", 10, 10, 300, 20) GUICtrlSetFont(-1, 11, 500, 0, $Calisto) $button = GUICtrlCreateButton("Cancel", 145, 70, 50, 30) Dim $Timer = TimerInit(), $i = 0 GUISetState () Do $msg = GUIGetMsg() If $msg = $button Then ExitLoop If TimerDiff($Timer) >= 1000 Then $i += 50 GUICtrlSetData($Progress_1, $i) $Timer = TimerInit() EndIf Until $i = 100 guictrlsetdata($Progress_1,0) EndFunc I know the last one doesnt work... But i think that u havnt made annything for the third one... U know... So the third one doesnt load at all... Annyway... Try to fix that last problem urself. *edit* U might wanna add If $check3 = 1 Then wait_progress () to function 3... I havnt tested yet tough... Ehh wai i mean that if check 3 = 1 and stuff...Add it below that i think. *edit again* U know what Im confuzed... Annyway.. I think u can just ignore what i wrote just.. Just use the "coded" part.... I think thats how u wanted it... I cant realy see another sulotion annyway. GL Edited July 2, 2007 by kp3 [s]My scripts =)Password protect process (with tray menu lol)Clickous meousDisable ctrl+alt+del and password protect folder...Andous herous lolKp3s security center v.1Click me[/s]Ok... You shouldnt use annyone of them cuz they use alot of memory and contain alot of errors and stuff.. I was a n00b :P Ignore it... And if u for some reason want to use them... Watch out for my realy bad spelling :I
dreamzboy Posted July 2, 2007 Author Posted July 2, 2007 Acctualy i dont understand most of ur code but :/I warned you, it's advanced coding. I copied and pasted your code, no good. Here's what I mean.User select program 1, 2, or 3 to run. Reference to check_1, check_2, and check_3.If user select program 1 and 2 to run, then program 1 will run. After program 1 is installed, then the progress bar will show up as a wait time (sleep) before executing program 2. The reason why I don't have anything for program 3 is because it's the last program to execute, so it doesn't need wait time. The problem I'm encountering is after program 1 executed, the progress bar showed up and stayed that way and it would not close before program 2 execute. Yes, I could have used progresson and progressoff function, but then I won't learn the cool GUI effect.I understand it's confusing, but I guess that's how beginner code it. The end is almost near, I just need someone to give me pointer to make that darn progress bar to work.Much appreciated.
dreamzboy Posted July 3, 2007 Author Posted July 3, 2007 Please help? I have deployed my knowledge and could not move further, could someone shine some light? Your help is important to me. I could not get the progress bar to close after the first program or the second program to execute. Refer to my previous post. expandcollapse popup#include <GuiConstants.au3> Opt ("TrayIconDebug", 1) GuiCreate ("MyGUI", 392, 323,-1, -1) $Checkbox_1 = GuiCtrlCreateCheckbox("Checkbox1", 20, 30, 100, 10) $Checkbox_2 = GuiCtrlCreateCheckbox("Checkbox2", 20, 60, 90, 20) $Checkbox_3 = GuiCtrlCreateCheckbox("Checkbox3", 20, 100, 90, 10) $Run = GUICtrlCreateButton ("Run", 20, 130, 50, 20) Dim $Progress_1 dim $check1 dim $check2 dim $check3 GuiSetState() getMsg() Func getMsg () Do $msg = GuiGetMsg() $check1 = GUICtrlRead ($Checkbox_1) $check2 = GUICtrlRead ($Checkbox_2) $check3 = GUICtrlRead ($Checkbox_3) Until $msg = $GUI_EVENT_CLOSE Or $msg = $Run If $msg = $GUI_EVENT_CLOSE Then Exit EndIf While $msg = $Run And $check1 = 4 And $check2 = 4 And $check3 = 4 MsgBox (0, "", "Please select a program to install.") getMsg () WEnd If $check1 = 1 Then function1 () If $check2 = 1 Or $check3 = 1 Then wait_progress () EndIf If $check2 = 1 Then function2 () If $check3 = 1 Then wait_progress () EndIf If $check3 = 1 Then function3 () getMsg () EndFunc Func function1 () MsgBox (0, "", "Running program 1", 2) EndFunc Func function2 () MsgBox (0, "", "Running program 2", 2) EndFunc Func function3 () MsgBox (0, "", "Running program 3", 2) EndFunc Func wait_progress () GuiCreate("Progress Bar", 361, 70,-1, -1) $Calisto = "Calisto MT" $Progress_1 = GuiCtrlCreateProgress(10, 40, 340, 20) GUICtrlSetColor (-1, 0x4169e1) $Label3 = GuiCtrlCreateLabel("Loading next program, please wait.", 10, 10, 300, 20) GUICtrlSetFont (-1, 11, 500, 0, $Calisto) GuiSetState() Do For $i = 0 To 100 Step 50 GUICtrlSetData ($Progress_1, $i) Sleep (1000) Next Until $i >= 100 $i = 0 EndFunc
PsaltyDS Posted July 3, 2007 Posted July 3, 2007 Please help? I have deployed my knowledge and could not move further, could someone shine some light? Your help is important to me. I could not get the progress bar to close after the first program or the second program to execute. Refer to my previous post. You had getmsg() calling itself in several places and some broken logic. Try this: expandcollapse popup#include <GuiConstants.au3> Opt("TrayIconDebug", 1) $hMain = GUICreate("MyGUI", 392, 323, -1, -1) $Checkbox_1 = GUICtrlCreateCheckbox("Checkbox1", 20, 30, 100, 20) $Checkbox_2 = GUICtrlCreateCheckbox("Checkbox2", 20, 60, 100, 20) $Checkbox_3 = GUICtrlCreateCheckbox("Checkbox3", 20, 90, 100, 20) $Run = GUICtrlCreateButton("Run", 20, 130, 50, 20) Dim $Progress_1 Dim $check1 Dim $check2 Dim $check3 GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Run $check1 = GUICtrlRead($Checkbox_1) $check2 = GUICtrlRead($Checkbox_2) $check3 = GUICtrlRead($Checkbox_3) If $check1 = 4 And $check2 = 4 And $check3 = 4 Then MsgBox(16, "Error", "You must select a checkbox first...", 5) ContinueLoop EndIf If $check1 = 1 Then function1() If $check2 = 1 Then function2() If $check3 = 1 Then function3() Exit EndSwitch WEnd Func function1() MsgBox(0, "", "Running program 1", 2) wait_progress() EndFunc ;==>function1 Func function2() MsgBox(0, "", "Running program 2", 2) wait_progress("Program 2") EndFunc ;==>function2 Func function3() MsgBox(0, "", "Running program 3", 2) wait_progress("Program 3") EndFunc ;==>function3 Func wait_progress($sText = "next program") $hProg = GUICreate("Progress Bar", 361, 70, -1, -1, -1, -1, $hMain) $Calisto = "Calisto MT" $Progress_1 = GUICtrlCreateProgress(10, 40, 340, 20) GUICtrlSetColor(-1, 0x4169e1) $Label3 = GUICtrlCreateLabel("Loading " & $sText & ", please wait.", 10, 10, 300, 20) GUICtrlSetFont(-1, 11, 500, 0, $Calisto) GUISetState(@SW_SHOW, $hProg) For $i = 0 To 100 GUICtrlSetData($Progress_1, $i) Sleep(50) Next GUIDelete($hProg) EndFunc ;==>wait_progress Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
dreamzboy Posted July 3, 2007 Author Posted July 3, 2007 wow...hands down to u. I gotta go back and learn the codes to fully understand. Works like a charm. Much thanks!
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