JimC Posted April 18, 2008 Posted April 18, 2008 Hello, I have written a gui which creates an unattended xp install. During the processing of files while reading in arrays, the gui appears to not be doing anything. What can I do to give the impression that something is going on. There are periods of time that could be interpreted as hangs. Thank in advance for any help.
weaponx Posted April 18, 2008 Posted April 18, 2008 (edited) You should provide a better decription of the actions being taken, so we can help provide a viable solution. AutoIt is not multithreaded so there are only certain things that can appear simultaneous. For example, if you are looping through an array with 1000 elements you could have a label on your gui showing the number of elements remaining. You could also have an edit box that acts as a log, showing if the last task was successful and its duration. Edited April 18, 2008 by weaponx
ChrisL Posted April 18, 2008 Posted April 18, 2008 (edited) How about using adlib to update a progressbar. #include <GUIConstants.au3> GUICreate("My GUI Progressbar",220,100, 100,200) $progressbar1 = GUICtrlCreateProgress (10,10,200,20) GUISetState () Global $iCnt = 0 Global $Direction = 1 AdlibEnable("_Progress",50) While 1 Sleep (1000) WEnd Func _Progress() If $Direction = 1 and $iCnt < 100 then GuiCtrlSetData($progressbar1,$iCnt) $iCnt += $Direction ElseIf $iCnt > 0 then $Direction = -1 GuiCtrlSetData($progressbar1,$iCnt) $iCnt += $Direction Else $Direction = 1 EndIf EndFunc Edited April 18, 2008 by ChrisL [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
ChrisL Posted April 18, 2008 Posted April 18, 2008 (edited) Or do a marquee #include <GUIConstants.au3> GUICreate("My GUI Progressbar",220,100, 100,200) $progressbar1 = GUICtrlCreateProgress (10,10,200,20,$PBS_MARQUEE); marquee works on Win XP and above GUISetState () AdlibEnable("_Progress",100) While 1 Sleep (1000) WEnd Func _Progress() GuiCtrlSetData($progressbar1,1) EndFunc Edited April 18, 2008 by ChrisL [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
weaponx Posted April 18, 2008 Posted April 18, 2008 You could go all out: expandcollapse popup#Include <GuiEdit.au3> #include <GUIConstants.au3> Const $numTasks = 20 GUICreate("My GUI") ; will create a dialog box that when displayed is centered GUISetState (@SW_SHOW) ; will display an empty dialog box GuiCtrlCreateLabel("Tasks completed:", 10, 10, 100,20) $tasks = GuiCtrlCreateLabel("50/100", 110, 10, 100,20) $progress = GUICtrlCreateProgress(10,50,330,20) $percent = GuiCtrlCreateLabel("100%", 350, 53, 100,20) $log = GuiCtrlCreateEdit("",10,80,380,310) ;Simulate tasks For $X = 1 to $numTasks $totalTimer = TimerInit() $relativePercent = ($X/$numTasks) * 100 ;Update completed task count GuiCtrlSetData($tasks,$X & "/" & $numTasks) ;Update progress bar GuiCtrlSetData($progress,$relativePercent) ;Update progress percent GuiCtrlSetData($percent, $relativePercent & "%") ;Fake task stuff _GUICtrlEdit_AppendText($log, "Starting task: " & $X & "/" & $numTasks & @CRLF) _GUICtrlEdit_AppendText($log, "Copying...") $copyTimer = TimerInit() ;Fake copy FakeFileCopy() If NOT @ERROR Then _GUICtrlEdit_AppendText($log, "OK") Else _GUICtrlEdit_AppendText($log, "FAIL") EndIf ;Append runtime $seconds = StringFormat("%.2f",TimerDiff($copyTimer) /1000) _GUICtrlEdit_AppendText($log, " (" & $seconds & "s)" & @CRLF) $executeTimer = TimerInit() ;Fake execute _GUICtrlEdit_AppendText($log, "Executing...") FakeExecute() If NOT @ERROR Then _GUICtrlEdit_AppendText($log, "OK") Else _GUICtrlEdit_AppendText($log, "FAIL") EndIf ;Append runtime $seconds = StringFormat("%.2f",TimerDiff($executeTimer) /1000) _GUICtrlEdit_AppendText($log, " (" & $seconds & "s)" & @CRLF) ;Append total runtime $seconds = StringFormat("%.2f",TimerDiff($totalTimer) /1000) _GUICtrlEdit_AppendText($log, "Duration: " & $seconds & "s" & @CRLF) ;Extra space _GUICtrlEdit_AppendText($log, @CRLF) Sleep(250) Next ; Run the GUI until the dialog is closed While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Wend Func FakeFileCopy() Return SetError(Random(0,1,1)) EndFunc Func FakeExecute() Return SetError(Random(0,1,1)) EndFunc
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