Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

MM Cron


  • Please log in to reply
2 replies to this topic
Andre
  • Members
  • 52 posts
  • Last active: May 22 2006 10:08 AM
  • Joined: 22 Jul 2005
Simple Cron utility to run some things.
(using it on my job)

; MM-Cron V1.0
;
; Syntax : MM-Cron <Time in Min.> <Program to execute> <Window Title> <X Position> <Y Position> <RW>
; If RW is supplied then the cron waits till the program to execute has ended.
;
;
; 2005, Andre


#Persistent
#SingleInstance off 
#NoTrayIcon

If A_IsCompiled
{
; Exit when not enough parameters.....
 If 0 < 5
 {
	MsgBox,,, Syntax : MM-Cron <Time in Min.> <Program to execute> <Window Title> <X Position> <Y Position> <RW>,5
	ExitApp
 }
}

Tijd = %1%
Program = %2%
Title =%3%
Xpos = %4%
YPos = %5%
RunW = Upper(%6%)

If Not A_IsCompiled ;just for testing
{
 Tijd = 1
 Program = cmd.exe
 Title = hallo
 Xpos = 100
 Ypos = 100
 RunW = RW
}

MaxProgress := Tijd * 60
TijdToGo := Tijd * 60000

SetTimer, CountDown, 1000

Gui, Add, Progress, w150 h20 cBlue  vMyProgress
Gui, Add, Text,, Interval :
Gui, Add, Text, w50 xp+50 VInterval 
Gui, Add, Text,xs, To go :
Gui, Add, Text, w50 xp+50 VTimeToGo
Gui, Add, Button, GRunNow xs w75, &Run Now
Gui, Add, Button, GExitNow xp+75 w75, &Exit
;Gui, -MinimizeBox
Gui, Show,X%Xpos% Y%Ypos% , %Title%
GuiControl, +Range0-%MaxProgress%, MyProgress 
Return

RunNow:
 SetTimer, CountDown, Off
 If RunW = RW
   RunWait, %Program%
 Else
   Run, %Program%
 
 SetTimer, CountDown, On
 TijdToGo := Tijd * 60000
 GuiControl,, MyProgress, 0
Return

ExitNow:
GuiClose:
ExitApp

CountDown:
 EnvSub, TijdToGo, 1000
 GuiControl,, MyProgress, +1
 GuiControl,, Interval, %Tijd% min.
 TimeTemp := 	TimeLog(TijdToGo/1000)
 GuiControl,, TimeToGo, %TimeTemp%
 If TijdToGo <= 0
 {
 SetTimer, CountDown, Off
 If RunW = RW
   RunWait, %Program%
 Else
   Run, %Program%
 SetTimer, CountDown, On
	TijdToGo := Tijd * 60000
	GuiControl,, MyProgress, 0	
 }
Return

;Function to convert seconds in to hh:mm:ss format
;T1 = value in seconds
TimeLog(T1)
  { 
     SetFormat, FLOAT, 02.0
     S := Mod(T1,60) + 0.0
     M := Mod((T1-S)/60,60)
     H := ((T1-S)/60 - M)/60
     return  H . ":" . M . ":" . S 
  }

Feel free to give suggestions/improvements.....

Andre

Veovis
  • Members
  • 389 posts
  • Last active: Mar 17 2009 12:24 AM
  • Joined: 13 Feb 2006
Very nice program! Well laid out, easy to understand.

Can't imagine what I (or you) would use it for though...
Posted Image
"Power can be given overnight, but responsibility must be taught. Long years go into its making."

Andre
  • Members
  • 52 posts
  • Last active: May 22 2006 10:08 AM
  • Joined: 22 Jul 2005
Hi,

Thnx for the comment.

Here on my job we use it to schedule various scripts running on an server.
Wenn i look through the window (serverroom) behind me i can see in one look the status of it.......

Andre