Sign in to follow this  
Followers 0
cypher175

Do Some Functions For a Certain Amount of Time..?

4 posts in this topic

what would the code look like if i wanted to "Do/Loop" Some Functions For a Certain Amount of Time..??

Say for 20Min and then after that then do something else..??

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You could try:

#include <GUIConstants.au3>
$timer = TimerInit()

While 1
    $Msg = GUIGetMsg()
    Switch TimerDiff($timer)
        Case 1 To 5000
            Function1()
        Case 5001 To 10000
            Function2()
        Case 10001 To 20000
            Exit

    EndSwitch
    If $Msg = $GUI_EVENT_CLOSE Then Exit
WEnd

Func Function1()
    ConsoleWrite(@CR & " Function 1 for 5000 ms  ")
EndFunc   ;==>Function1

Func Function2()
    ConsoleWrite(@CR & " Function 2 for 5000 ms  ")
EndFunc   ;==>Function2

Hope that helps

Cheers

NBJ

Edited by NBJ

Share this post


Link to post
Share on other sites

is there any other way to do this..??

yer code looks like it will only do 2 function for 2 specific time periods..

I want to do a flow of functions in a loop for 20Min..

is there anyway to do it so i don't have to specify time periods for each specific function that i want to perform..??

that way each function can perform without a time constraint, but when the 20Min is up it moves on to the next code/functions out of the loop in the script..

is there any other way to do this like i want to do..??

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
$timer = TimerInit()

While 1
    $Msg = GUIGetMsg()
    Switch TimerDiff($timer)
        Case 1 To 10000
            Function1()
            Function2()
        Case 10001 To 20000
            Exit

    EndSwitch
    If $Msg = $GUI_EVENT_CLOSE Then Exit
WEnd

Func Function1()
    ConsoleWrite(@CR & " Function 1 for 5000 ms  ")
EndFunc   ;==>Function1

Func Function2()
    ConsoleWrite(@CR & " Function 2 for 5000 ms  ")
EndFunc   ;==>Function2

?


Giggity

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