Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Repeat Function every 30 minutes


  • Please log in to reply
12 replies to this topic

#1 0000

0000

    Wayfarer

  • Active Members
  • Pip
  • 66 posts

Posted 24 November 2007 - 12:06 PM

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







#2 Tiger

Tiger

    Polymath

  • Active Members
  • PipPipPipPip
  • 220 posts

Posted 24 November 2007 - 12:20 PM

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

My UDFs:- _RegEnumKeyPosted Image

#3 Emiel Wieldraaijer

Emiel Wieldraaijer

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 711 posts

Posted 24 November 2007 - 12:56 PM

You are asking for an example which is in the helpfile

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

Best regards,Emiel WieldraaijerPosted Image

#4 0000

0000

    Wayfarer

  • Active Members
  • Pip
  • 66 posts

Posted 24 November 2007 - 01:08 PM

Hmm but then my script will stop.
And then script woudn't do what he had t odo :P.
More exapmles please ;)
Thanx!

#5 Emperor

Emperor

    Adventurer

  • Active Members
  • PipPip
  • 122 posts

Posted 24 November 2007 - 03:35 PM

Hmm but then my script will stop.

Perhaps take a look at AdlibEnable in the help file.

#6 Jex

Jex

    Polymath

  • Active Members
  • PipPipPipPip
  • 206 posts

Posted 24 November 2007 - 04:00 PM

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

Edited by Jex, 24 November 2007 - 04:02 PM.


#7 0000

0000

    Wayfarer

  • Active Members
  • Pip
  • 66 posts

Posted 24 November 2007 - 06:28 PM

WARNING: $TimerDiff possibly not declared/created yet
$TimerDiff += TimerDiff($Timer)

Getting error, where's problem ?

#8 karman

karman

    Wayfarer

  • Active Members
  • Pip
  • 68 posts

Posted 24 November 2007 - 07:04 PM

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

#9 Valuater

Valuater

    www.PayFreeWireless.com

  • MVPs
  • 11,213 posts

Posted 24 November 2007 - 07:57 PM

from Autoit Wrappers


AutoIt         
;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, 24 November 2007 - 07:58 PM.

Posted Image

Clic The Pic!!!


#10 zfisherdrums

zfisherdrums

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 391 posts

Posted 24 November 2007 - 08:03 PM

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, 24 November 2007 - 08:22 PM.


#11 0000

0000

    Wayfarer

  • Active Members
  • Pip
  • 66 posts

Posted 24 November 2007 - 09:55 PM

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

#12 crislivinitup

crislivinitup

    Adventurer

  • Active Members
  • PipPip
  • 105 posts

Posted 25 November 2007 - 12:22 AM

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"

#13 esmano

esmano

    Seeker

  • New Members
  • 4 posts

Posted 25 November 2007 - 11:53 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users