Jump to content

Repeat Function every 30 minutes


0000
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

NEWHeader1.png

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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"

Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...