HumperHard Posted March 5, 2009 Share Posted March 5, 2009 I cant get the progress bar to move besides when I click the close button. How do you set it so it will update as its completing task within the script? expandcollapse popup#include <Array.au3> #include <File.au3> #include <GuiConstantsEx.au3> #include <Misc.au3> _Singleton("CreateUser") ; ######################################################################################### ; # Create GUI ; ######################################################################################### GUICreate("Account Creation", 300, 300) ; PROGRESS $progress = 0 $progressbar = GUICtrlCreateProgress(10, 10, 200, 20) ;GuiCtrlCreateProgress(60, 80, 150, 20) GuiCtrlSetData($progressbar, $progress) $label = GuiCtrlCreateLabel("Progress:", 5, 82) GuiSetState(@SW_SHOW) ; ######################################################################################### ; # GUI MESSAGE LOOP ; ######################################################################################### While 1 if GUICtrlRead($progressbar)<>$progress Then GUICtrlSetData($progressbar, $progress) EndIf $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd ; ######################################################################################### ; # Progress Bar ; ######################################################################################### ;ProgressOn ( "Account Creation", "IA Tool Kit" ) $UserName = ("Tester") $Password = ("password") $progress = $progress + 10 GuiCtrlSetData($progressbar, $progress) ; ######################################################################################### ; # List users on the computer that have profiles created ; ######################################################################################### $oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler Local $objDomain = ObjGet("WinNT://" & @ComputerName & "" ) Dim $filter[2] = ["user"] $objDomain.Filter = $filter $FileList=_FileListToArray("C:\Documents and Settings\","*",2) ;;search this folder for any folders within If @Error=1 Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf ;$aaUser = "" $listOfProfiles = "" $y = 0 For $aUser In $objDomain For $x = 1 to $FileList[0] Switch $FileList[$x] Case $aUser.Name ;; users to process $y = $y + 1 $listOfProfiles = $listOfProfiles & @CR & $y & " : " & $aUser.Name Case Else ;; ignore all other users EndSwitch $progress = $progress + 5 ;ProgressSet ( $progress ) ;GUICtrlSetData(-1, $progress) GuiCtrlSetData($progressbar, $progress) Next Next MsgBox(0+48+4096, "List of Users with Profiles!", $listOfProfiles) ;COM Error function Func ComError() If IsObj($oMyError) Then $HexNumber = Hex($oMyError.number, 8) ConsoleWrite($oMyError.scriptline & ' $HexNumber = ' & $HexNumber & "Windescription is: " & $oMyError.description & "|" & $oMyError.windescription & @lf);### Debug Console SetError($HexNumber) Else SetError(1) EndIf Return 0 EndFunc ;==>ComError ;ProgressSet ( $progress ) $progress = $progress + 10 GuiCtrlSetData($progressbar, $progress) ; ######################################################################################### ; # Create Tester account ; ######################################################################################### $strComputer = @ComputerName $colAccounts = ObjGet("WinNT://" & $strComputer & "") $objUser = $colAccounts.Create("user", $UserName) $objUser.SetPassword ($Password) $objUser.Put ("Fullname", "Tester") $objUser.Put ("Description", "Testing Account") $objUser.SetInfo ;ProgressSet ( 70 ) $progress = $progress + 5 GuiCtrlSetData($progressbar, $progress) ; ######################################################################################## ; # Add IATester to Administrator and Auditors ; ######################################################################################## $objGroup = ObjGet("WinNT://" & $strComputer & "/Administrators") $objGroup.Add("WinNT://"&$UserName) $objGroup = ObjGet("WinNT://" & $strComputer & "/Auditors") $objGroup.Add("WinNT://"& $UserName) ;ProgressSet ( 100 ) $progress = 100 GuiCtrlSetData($progressbar, $progress) ; ######################################################################################## ; # Force logout ; ######################################################################################## ;shutdown (0) Link to comment Share on other sites More sharing options...
Authenticity Posted March 5, 2009 Share Posted March 5, 2009 That is how you instructed your script to do. Look at the message loop, until $msg <> $GUI_EVENT_CLOSE the progress bar never gets updated and only if the user close it the rest of the source is getting executed. Link to comment Share on other sites More sharing options...
HumperHard Posted March 5, 2009 Author Share Posted March 5, 2009 That is how you instructed your script to do. Look at the message loop, until $msg <> $GUI_EVENT_CLOSE the progress bar never gets updated and only if the user close it the rest of the source is getting executed.I see that but how do I set it to also update after certain events occur? Like creating a account Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 5, 2009 Share Posted March 5, 2009 This cries out for the GUI to be in Event Mode. Set GuiOnEventMode and set a GUI event for $GUI_EVENT_CLOSE. Then you can go on to the rest of the script without bothering to be in a message loop. 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 Link to comment Share on other sites More sharing options...
HumperHard Posted March 5, 2009 Author Share Posted March 5, 2009 This cries out for the GUI to be in Event Mode. Set GuiOnEventMode and set a GUI event for $GUI_EVENT_CLOSE. Then you can go on to the rest of the script without bothering to be in a message loop. but will that allow me to set where the updating of the progress bar occurs? Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 5, 2009 Share Posted March 5, 2009 but will that allow me to set where the updating of the progress bar occurs?I don't really understand the question. What does that have to do with what mode the GUI is in? You have the ControlID of the progressbar control, you can update it anywhere\anytime you want. In fact, if you use ProgressOn(), you don't have to create your GUI or worry about the mode at all! Since your GUI has nothing but the progressbar and some text, why bother? Just use ProgressOn(), then ProgressSet() as required. 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 Link to comment Share on other sites More sharing options...
HumperHard Posted March 5, 2009 Author Share Posted March 5, 2009 I don't really understand the question. What does that have to do with what mode the GUI is in? You have the ControlID of the progressbar control, you can update it anywhere\anytime you want. In fact, if you use ProgressOn(), you don't have to create your GUI or worry about the mode at all! Since your GUI has nothing but the progressbar and some text, why bother? Just use ProgressOn(), then ProgressSet() as required. Well the rest of the code was just making sure I had the code right before putting this into a GUI... I am trying to put the accounts in a text box within the GUI. ControlID was probably what I was looking for. I know it works with the ProgressOn().. thats what I was using before. Thanks I will look into ControlID Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 5, 2009 Share Posted March 5, 2009 Well the rest of the code was just making sure I had the code right before putting this into a GUI... I am trying to put the accounts in a text box within the GUI. ControlID was probably what I was looking for. I know it works with the ProgressOn().. thats what I was using before. Thanks I will look into ControlIDOK. You saved the ControlID in $progressbar when you created it. Now you can do ControlSetData($progressbar, $iNewProgress) anywhere in the script. 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 Link to comment Share on other sites More sharing options...
HumperHard Posted March 5, 2009 Author Share Posted March 5, 2009 OK. You saved the ControlID in $progressbar when you created it. Now you can do ControlSetData($progressbar, $iNewProgress) anywhere in the script. Ok so I had commented out the line I needed to make it work.. lol... working now.. Thanks 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