Sign in to follow this  
Followers 0

Repeat Function every 30 minutes

13 posts in this topic

Posted

Can somebody give me example with TimeDiff and TimerInit how to count minutes and if 30minutes gone, then show msgbox :P?

Thanx

Share this post


Link to post
Share on other sites



Posted

MsgBox(0, "", "Start")
Sleep(1800000)
MsgBox(0, "", "End")

Share this post


Link to post
Share on other sites

Posted

You are asking for an example which is in the helpfile

$begin = TimerInit()
Sleep(1800000)
$dif = TimerDiff($begin)
MsgBox(0,"Time Difference",$dif)

Share this post


Link to post
Share on other sites

Posted

Hmm but then my script will stop.

And then script woudn't do what he had t odo :P.

More exapmles please ;)

Thanx!

Share this post


Link to post
Share on other sites

Posted

Hmm but then my script will stop.

Perhaps take a look at AdlibEnable in the help file.

Share this post


Link to post
Share on other sites

Posted (edited)

While 1
    $Timer = TimerInit()
   
    ;Your scripts here
   
    $TimerDiff += TimerDiff($Timer)
    If $TimerDiff >= 1800000 Then
		MsgBox("","",$TimerDiff)
		$TimerDiff = 0
	EndIf
WEnd

Edited by Jex

Share this post


Link to post
Share on other sites

Posted

WARNING: $TimerDiff possibly not declared/created yet

$TimerDiff += TimerDiff($Timer)

Getting error, where's problem ?

Share this post


Link to post
Share on other sites

Posted

his code is totally wrong.. thats why

while 1

$timer = timerinit()
do
; do something here while waiting
Sleep(10)
until timerdiff($timer) >= 1800000; exit loop when 1800 seconds

msgbox(0, "", "hello! 30 minutes have passed", 2)

wend; and restart..

this code will show a msg box every 30 minutes.. until you exit the program.. :P

Share this post


Link to post
Share on other sites

Posted (edited)

from Autoit Wrappers

;Time Machine #1
;Minutes/seconds/miliseconds

; Author - Valuater

$Minutes = 90 ; will wait 90 minutes

Local $60Count = 0, $begin = TimerInit()
While $Minutes > $60Count
   
    $dif = TimerDiff($begin)
    $dif2 = StringLeft($dif, StringInStr($dif, ".") -1)
    $Count = int($dif/1000)
    $60Count = Int($Count / 60)
   
    ToolTip("Minutes Required = " & $Minutes & @CRLF & "Minutes Past = " & $60Count & @CRLF & "Seconds Count = " & $Count & @CRLF & "Mili-Seconds Count = " & $dif2, 20, 20, "Time Machine #1", 1)
   
    Sleep(20)
   
WEnd

MsgBox(64, "Time-Up!!", "Your " & $Minutes & " minutes have passed    ")

... and there are alot more great additions to your script in Autoit Wrappers

8)

Edited by Valuater

Share this post


Link to post
Share on other sites

Posted (edited)

Hello 0000,

I know it doesn't use TimerX functions as you requested, but Emperor made a good point about AdlibEnable. Here's an example:

; This is the function to be called by AdlibEnable...
Func ShowMessageBox()
	MsgBox( 0, "", "Test" )
EndFunc

; Setup our function to be called every 30 minutes...
Dim $timeInMilliseconds = 1800000
AdlibEnable( "ShowMessageBox", $timeInMilliseconds )

; All code below here is simulated script activity
Dim $x = 0
While 1
	$x += 1
	ConsoleWrite( $x & @CRLF)
	Sleep ( 1000 )
Wend

Just another way of doing it, that's all.

Zach...

Edited by zfisherdrums

Share this post


Link to post
Share on other sites

Posted

his code is totally wrong.. thats why

while 1

$timer = timerinit()
do
; do something here while waiting
Sleep(10)
until timerdiff($timer) >= 1800000; exit loop when 1800 seconds

msgbox(0, "", "hello! 30 minutes have passed", 2)

wend; and restart..

this code will show a msg box every 30 minutes.. until you exit the program.. :P

That was very good but I added Function between Sleep and it didn't show it I will try other ways

Share this post


Link to post
Share on other sites

Posted

You could also use the adlib function which executes a function every so often. It works on the same principle, the only difference is you can run any code you want and when 30 minutes is up, it will stop in the middle of execution to execute that function. Check it out in the help file. "adlib"

Share this post


Link to post
Share on other sites

Posted

It also can be done very simple, check this:

CODE

my_msgbox() ;Trigger messagebox-function

Func my_msgbox()

Msgbox(0,"","your msgbox") ;your messagebox

loop() ; go to the sleep-function

EndFunc

Func loop()

Sleep(1800000) ;wait 30 minutes

my_msgbox() ;Go back to the messagebox-function

EndFunc

Cheers :P

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