Jump to content
Sign in to follow this  
Voide

Pause Script While MsgBox is shown.

Recommended Posts

Voide

Basicly, what I want to do is start a timer as I run the script, after 3,5 minutes I want it to prompt me with a MsgBox, as it prompts me I want the script to pauze, then as I click OK I want the script to start the timer again... So far I have:

$i = 0

While $i <= 10

sleep(210000)

MsgBox(0, "Feed your MAG!", "I'm hungry! D:")

WEnd

It seems to loop infinitely as intended but I haven't found a way to pause the timer as it shows me the MsgBox (Yes, I'm very new to this)

Thanks in advance.

Share this post


Link to post
Share on other sites
PsaltyDS

Basicly, what I want to do is start a timer as I run the script, after 3,5 minutes I want it to prompt me with a MsgBox, as it prompts me I want the script to pauze, then as I click OK I want the script to start the timer again... So far I have:

$i = 0

While $i <= 10

sleep(210000)

MsgBox(0, "Feed your MAG!", "I'm hungry! D:")

WEnd

It seems to loop infinitely as intended but I haven't found a way to pause the timer as it shows me the MsgBox (Yes, I'm very new to this)

Thanks in advance.

That doesn't make any sense. What timer is not paused while the MsgBox() is displayed? Also, nothing increments $i so the While condition never changes and that While/WEnd loop never ends.

muttley


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

Share this post


Link to post
Share on other sites
Voide

I just want the script to restart the sleep(210000) timer as I click ok in the msgbox... As of now I think it just restarts instantly while displaying the msgbox.

And yeah, I intend it to loop infinitely this way, keep in mind that I know next to nothing about autoit ^^ it just happened to loop when I put in that While $i thingy...

Share this post


Link to post
Share on other sites
bogQ

I just want the script to restart the sleep(210000) timer as I click ok in the msgbox... As of now I think it just restarts instantly while displaying the msgbox.

And yeah, I intend it to loop infinitely this way, keep in mind that I know next to nothing about autoit ^^ it just happened to loop when I put in that While $i thingy...

No, its working OK!!

it sleep 210 seconds after msgbox is clicked

While 1
    sleep(5000)
    MsgBox(0, "Feed your MAG!", "I'm hungry! D:")
WEnd

test it on 5 sec. press OK after 3 sec. and itl wait 5 more sec. until new msgbox

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites
Voide

No, its working OK!!

it sleep 210 seconds after msgbox is clicked

While 1
    sleep(5000)
    MsgBox(0, "Feed your MAG!", "I'm hungry! D:")
WEnd
Ow... My bad, thanks! muttley

Share this post


Link to post
Share on other sites
PsaltyDS

I just want the script to restart the sleep(210000) timer as I click ok in the msgbox... As of now I think it just restarts instantly while displaying the msgbox.

That is what happens now. When you click OK, the loop goes back to the top and the Sleep() is executed again. After Sleep() times out, the MsgBox() comes up again. The Sleep() timer is already expired before your MsgBox() comes up, and Sleep() doesn't happen again until after the MsgBox() is cleared.

While a MsgBox() is up, the script is completely stopped, which is why there is an optional timeout parameter for MsgBox().

And yeah, I intend it to loop infinitely this way, keep in mind that I know next to nothing about autoit ^^ it just happened to loop when I put in that While $i thingy...

Don't bother with $i then, just use:
While 1

    ; ... your loop code here

WEnd

The problem with that, is you have no way to exit the script. One nice way to do that is HotKeySet():

HotKeySet("{ESC}", "_Quit")

While 1

    ; ... your loop code here

WEnd

Func _Quit()
     Exit
EndFunc

Now you can just hit ESC to exit the script (ESC can be changed to other keys as required).

muttley


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

Share this post


Link to post
Share on other sites
Voide

That is what happens now. When you click OK, the loop goes back to the top and the Sleep() is executed again. After Sleep() times out, the MsgBox() comes up again. The Sleep() timer is already expired before your MsgBox() comes up, and Sleep() doesn't happen again until after the MsgBox() is cleared.

While a MsgBox() is up, the script is completely stopped, which is why there is an optional timeout parameter for MsgBox().

Don't bother with $i then, just use:

While 1

; ... your loop code here

WEnd

The problem with that, is you have no way to exit the script. One nice way to do that is HotKeySet():

HotKeySet("{ESC}", "_Quit")

While 1

; ... your loop code here

WEnd

Func _Quit()
     Exit
EndFunc

Now you can just hit ESC to exit the script (ESC can be changed to other keys as required).

muttley

Nice, thanks alot!

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  

×