Jump to content

Automatically run program every 15 min


Held51
 Share

Recommended Posts

@Held51,

Welcome to our forum^_^. Day ago I have the same concern as you have however, what I need is per day count, so, I use sleep() function to do my staff but @Melba23 responded me in my inquiry. So, basing of his idea, i made a simple timer that will run your program whenever you want to run your program within that day.

HotKeySet("{ESC}", "_Exit") ; just incase you want to end the program
$Mins = 15 ; this is where you add your @min
$Timer = TimerInit()

While 1
    If TimerDiff($Timer) > ($Mins * 60000) Then ; count per minute multiplied by 60sec. 
        ConsoleWrite("15 minutes have passed!" & @CRLF) ; console to see if running or what ever you wanted to do. Some staff
        $Timer = TimerInit()
    EndIf
WEnd
Func _Exit()
    Exit
EndFunc

Here's my post if you like to have it per day count.:D

 

KS15

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

3 hours ago, Held51 said:

I tried to run my program every 15 min with @MIN and I did not succeed, could they help me?

Can you post your script so that we can have a look at what is going wrong?

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

8 hours ago, KickStarter15 said:

@Held51,

Welcome to our forum^_^. Day ago I have the same concern as you have however, what I need is per day count, so, I use sleep() function to do my staff but @Melba23 responded me in my inquiry. So, basing of his idea, i made a simple timer that will run your program whenever you want to run your program within that day.

HotKeySet("{ESC}", "_Exit") ; just incase you want to end the program
$Mins = 15 ; this is where you add your @min
$Timer = TimerInit()

While 1
    If TimerDiff($Timer) > ($Mins * 60000) Then ; count per minute multiplied by 60sec. 
        ConsoleWrite("15 minutes have passed!" & @CRLF) ; console to see if running or what ever you wanted to do. Some staff
        $Timer = TimerInit()
    EndIf
WEnd
Func _Exit()
    Exit
EndFunc

Here's my post if you like to have it per day count.:D

 

KS15

What about AdlibRegister() ? :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Here's a template showing how I schedule my daily or weekly repeating tasks, at home and at work. Works like a charm. Just make sure that the Sleep value at the end of each task is at least 61 seconds [Sleep(61000)]; otherwise, you'll get more than one instance of the same task running simultaneously.

; Scheduler.au3
; Task Scheduler (AutoIt v3) [CLD rev.2/27/17]
; --------------------------------------------
#cs

Macro reference:
@YEAR       4-digit year
@MON        Month. Range: 01-12
@MDAY       Day of month. Range: 01-31
@HOUR       Hour. Range: 00-23
@MIN        Minutes. Range: 00-59
@SEC        Seconds. Range: 00-59
@MSEC       Millseconds. Range: 00-999
@WDAY       Numeric day of week. Range: 1-7 (Sunday-Saturday)
@YDAY       Day of year. Range: 001-366

#ce

#include <Misc.au3>
_Singleton(@ScriptName, 0)

; Machine ID variables
$bHome = False
$bWork = False
Select
    Case FileExists("d:\path\foo\*")
        $bHome = True
    Case FileExists("e:\path\bar\*")
        $bWork = True
EndSelect

; Path variables
Select
    Case $bHome
        $sXyDir = "d:\path\foo\xy"
        $sLocateDir = "f:\Locate32"
        $svDosDir = "d:\path\foo\vDos"

    Case $bWork
        $sXyDir = "d:\path\bar\xy"
        $sLocateDir = "g:\Locate32"
        $svDosDir = "d:\path\bar\vDos"
EndSelect

; Other variables
$sNewsURL = "http://www.wnyc.org/stream/wnyc-fm939/windows.asx"
; -------------------------------------------------------------------

WHILE 1
    $iNow = @HOUR & @MIN

    Select

        Case $bHome And $iNow = 0000
            SoundPlay($sXyDir & "\maid.mp3", 0)
            MsgBox(0, "It's Midnight...", "Time for sleep!", 60)
            Sleep(61000)

        Case $bHome And $iNow = 0005
            ShellExecuteWait($sLocateDir & "\Updtdb32.exe")
            Sleep(61000)

        Case $bHome And @WDAY = 7 And $iNow = 0025
            ShellExecute($svDosDir & "\VDP-checkinstall.exe")
            Sleep(61000)

        Case $bWork And ($iNow = 1108 Or $iNow = 1655)
            Run($sLocateDir & "\Locate32.exe")
            Sleep(1000)
            WinActivate("Locate:")
            Sleep(2000)
            Send("{F9}")
            Sleep(5000)
            WinKill("Locate:")
            Sleep(100)
            WinActivate("vDos")
            Sleep(61000)

        Case $bWork And $iNow = 1800
            Local $curw = WinGetTitle("[active]")
            If WinActive("media player") Then
                WinKill("media player")
                Sleep(500)
            EndIf
            ShellExecute(@ScriptDir & "\start.exe", "_ " & $sNewsURL, @ScriptDir, "Open", 1)
            Sleep(3000)
            WinActivate("firefox")
            WinWaitActive("firefox")
            Sleep(500)
            Send("^w")
            WinActivate($curw)
            Sleep(61000)

        Case $bWork And $iNow = 1808
            WinKill("media player")
            Sleep(61000)

        Case $bWork And $iNow = 1825
            MsgBox(64, "Reminder: 6:25pm", "Time to go home!", 300)
            Sleep(61000)
        
    EndSelect

    Sleep(500)
WEND

 

Edited by CarlD
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...