Sign in to follow this  
Followers 0
pitt1al

For Loop timer randomly hanging

7 posts in this topic

#1 ·  Posted (edited)

for $i = 60 To 0 Step -5
   MsgBox(0, "Waiting for Thaw Script to finish", $i+5 & " Seconds Remaining", 5)
Next

I actually have two loops like this.  This one counts down from 60 the other counts down from 600.  It is a timer used to wait while a program intializes before handling a handful of other tasks.

This particular piece of code tends to count down to 50 (from 60) and then it just stops counting down.  The window remains popped up saying 50 seconds remain.  I right click the autoit icon in the lower right and uncheck script paused and it doesnt do anything.  I dont believe its actually paused, but right clicking there pauses it.  If i press the OK button on the popped up window it picks up right where it left off and finishes counting down. 

Any ideas why it would just pause the for loop and wait for me to press OK on the MsgBox window before continuing?

Thanks

Edited by pitt1al

Share this post


Link to post
Share on other sites



pitt1al,

Welcome to the AutoIt forum. :)

Your code works fine for me - what is going on in this "Thaw Script" while you are looping? :huh:

You might want to look at some other possibilities: a marquee progress bar which indicates that something is going on but does not give a countdown, or perhaps my ExtMsgBox UDF (the link is in my sig) which has a seconds countdown mode. ;)

Finally, is there no way of telling when this "Thaw Script" has terminated so that you can resume when required rather than after a predetermined time? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

That is the entirety of the for loop.  It exists solely to count down.  After that loop finishes a couple RunWait() commands are used to set up the next logon script, and install an MSI.  It never gets to those steps though because the loop hangs at 50 seconds remaining. 

While that For Loop is running ThawScript.ps1 (powershell) is doing a Start-Sleep -s 20 to let the computer finish loading the desktop, and then running the DeepFreeze command line to Thaw/Unlock the workstation. 

Both ThawScript.ps1 and this script with the for loop (AutItFaronicsInstalls.au3/exe) are set in the registry as runonce keys.  Because the device is in a frozen state both keys had to be set to run once at the same time, the timer here that is causing me troubles exists solely to make sure that AutoITFaronicsInstalls.exe does not run before ThawScript.ps1 finishes. I need ThawScript.ps1 to finish but I cant have AutoItFaronicsInstalls.exe immediately start because I need the reboot to occur.

Step 1 Device is imaged, ThawScript.ps1 and AutoItFaronicsInstalls.exe are added to the registry RunOnce key. DeepFreeze installs and reboots the computer in a FROZEN state

Step 2 Device auto logs in, ThawScript.ps1 and AutoItFaronicsInstalls.exe are launched automatically.  ThawScript.ps1 waits 20 seconds for the desktop to load and then uses the command line to Thaw DeepFreeze and reboot the device.  While this is happening AutoItFaronicsInstalls.exe is doing its 60 second countdown but the computer is rebooted before the 60 seconds is up (it hangs at 50 seconds though)

Step 3 Device auto logs in again.  Since it was froze last time the 2 reg keys did not clear so ThawScript.ps1 runs again but has no effect since it is already thawed.  Again, AutoITFaronicsInstalls.exe hangs at 50 seconds, but it should count down and then do some reg edits and install some msi's but it never gets that far. Then its last task is to Freeze Deepfreeze on the machine. 

Share this post


Link to post
Share on other sites

To me it seems like my MsgBox isnt timeing out/closing after 5 seconds like it is supposed to and so it never moves on to the next iteration. 

Share this post


Link to post
Share on other sites

pitt1al,

All that makes as much sense to me as if it were written in Chinese - but as you say:

While that For Loop is running ThawScript.ps1 (powershell) is doing a Start-Sleep -s 20 to let the computer finish loading the desktop

I wonder if the system is just not letting the MsgBox API call run at that point as that would explain the symptoms. :huh:

Why not give my UDF a try - it creates its own GUI and so does not depend on the API. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Yep, im digging through the documentation to figure out just how to use EXTMSGBOX right now. 

Share this post


Link to post
Share on other sites

pitt1al,

Not very difficult to master: ;)

#include "ExtMsgBox.au3"
_ExtMsgBox (128, "Exit", "Timer", "Timing down from 60", 60)
M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0