panhockey1025 Posted November 29, 2006 Posted November 29, 2006 Quick question. I was trying to figure out how to get my script to execute on a specific time and date but I couldn't figure out how to do it. Tell me if I'm wrong... I believe I could use the _DateIsValid function to verify the date. I don't know how to verify the time. If anyone could show me some example scripts that would be great! Thanks
panhockey1025 Posted November 29, 2006 Author Posted November 29, 2006 All I was trying to do was create a birthday script where it executed on my birthday at a certain time and said happy birthday. It seemed like it would be simple to do? Anyone got any ideas?
Developers Jos Posted November 29, 2006 Developers Posted November 29, 2006 There are many _Date.. functions available that can do this for you .... I am sure you can also find many posts with a similar question ... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Helge Posted November 29, 2006 Posted November 29, 2006 I answered this a while back for another user, where I showed how to simply storethe the dates and names in a INI-file. Check this post.
panhockey1025 Posted November 29, 2006 Author Posted November 29, 2006 So what about a specific time?
Helge Posted November 29, 2006 Posted November 29, 2006 Check out the date-macros listed in the helpfile. Basic code :If @MON = 7 AND @MDAY = 13 AND @HOUR = 9 AND @MIN = 30 Then MsgBox(64, "", "It's your birthday !")
panhockey1025 Posted November 29, 2006 Author Posted November 29, 2006 Thanks! Thats just what I've been searching for!
panhockey1025 Posted December 1, 2006 Author Posted December 1, 2006 Actually one more question.... Say I wanted that script to run in the background and then when the clock turned to a certain time it then went ahead and poped up the message box. How would I go about doing that?
martin Posted December 1, 2006 Posted December 1, 2006 Actually one more question....Say I wanted that script to run in the background and then when the clock turned to a certain time it then went ahead and poped up the message box. How would I go about doing that?I have a fairly simple script (50 lines) which runs permanently on my PC. When the time gets to 8pm, it pops up a message asking me if I want to run my backup program. If I ignore it or say yes starts the backups. If I say no it asks if it should try again in 1 hour.If that sounds like what you want I'll post it for you. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
panhockey1025 Posted December 1, 2006 Author Posted December 1, 2006 (edited) Ya thats basically what I want. Martin could you go ahead and post that script. I'm kind of interested in looking at it actually. I want something thats going to permantly run in the background and then when it hits a certain time like you said it will cause an action. Take this code: If @MON = 7 AND @MDAY = 13 AND @HOUR = 9 AND @MIN = 30 Then MsgBox(64, "", "It's your birthday !") I want it to keep checking to see if it is the correct time and date.... and if it is to cause the action of the MsgBox Can someone edit my code so i can could do that? Thanks Edited December 1, 2006 by panhockey1025
martin Posted December 1, 2006 Posted December 1, 2006 Ya thats basically what I want. I want something thats going to permantly run in the background and then when it hits a certain time like you said it will cause an action. Thanks OK this is it, best of luck. This script is just to start a program running at the same time every day but it might get you started. expandcollapse popup;schedule to run ZipBak.exe at certain time ;zipback will make backups according to instructions in file backlist.blt then exit HotKeySet("^!y", "MyExit");CTRL ALT Y will kill this program $task1done = 0 $debug = 0 $g_szVersion = "mg_sched V1.2" If WinExists($g_szVersion) Then MsgBox(0,'Scheduler error.',$g_szVersion & ' is already running!') Exit; It's already running EndIf $defaultstart = 20;I want this to operate between 8pm $defaultToTime = 7; and 7am $fromtime = $defaultstart $totime = $defaultToTime ;MsgBox(0,'','Working dir is ' & @WORKINGDIR) While 1 ;MsgBox(0,'','start of loop in zipback',2) If $fromtime > $totime Then $totime = 24 + $totime EndIf If (@HOUR >= $fromtime) AND (@HOUR < $totime) AND ($task1done = 0) Then If MsgBox(4,'Scheduler V1.2 ( start at' & $fromtime & ')','Start backups?',$defaultstart) = 7 Then;No pressed If MsgBox(4,'Postpone option.','Try agin in 1 hour?') = 7 Then $task1done = 1 Else $fromtime = Mod(@HOUR + 1,24) if $fromtime = 0 then $fromtime = 24 If $fromtime = $totime Then $totime = Mod($totime + 1,24);since said yes try again in 1 hr can only do this by extending $totime EndIf EndIf Else $val = RunWait('zipback.exe');zipback.exe and backlist.blt must be in same directory as schedule.exe If $debug Then MsgBox(0, "ZipBack returned with exit code:", $val,2) $task1done = 1 $fromtime = $defaultstart $totime = $defaultToTime EndIf EndIf If $task1done = 1 Then If @HOUR < $defaultstart AND @HOUR >= $defaultToTime Then $task1done = 0 $fromtime = $defaultstart $totime = $defaultToTime EndIf EndIf Sleep(100000);100 sec WEnd Func MyExit() MsgBox(0,"Schedule au3 " ,"Aborted Scheduler.") Exit EndFunc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
panhockey1025 Posted December 1, 2006 Author Posted December 1, 2006 That is a pretty interesting script and I can understand what is happening throughout it but I am a complete noob to programming. Could someone modify this line of code? I would like it to check to see if it is the correct time and date every minute and if it is I would like it to display the MsgBox. If @MON = 7 AND @MDAY = 13 AND @HOUR = 9 AND @MIN = 30 Then MsgBox(64, "", "It's your birthday !") Would it just be like a constant For...Next script until it is true? I'm not really sure how to make it work properly.
lcgreenwald Posted December 1, 2006 Posted December 1, 2006 (edited) Here is one way to do it. #NoTrayIcon While True If @MON = 7 And @MDAY = 13 And @HOUR = 9 And @MIN = 30 Then MsgBox(64, "", "It's your birthday !") ExitLoop EndIf Sleep(1000) WEnd Edited December 1, 2006 by lcgreenwald
martin Posted December 1, 2006 Posted December 1, 2006 (edited) That is a pretty interesting script and I can understand what is happening throughout it but I am a complete noob to programming. Could someone modify this line of code? I would like it to check to see if it is the correct time and date every minute and if it is I would like it to display the MsgBox. If @MON = 7 AND @MDAY = 13 AND @HOUR = 9 AND @MIN = 30 Then MsgBox(64, "", "It's your birthday !") Would it just be like a constant For...Next script until it is true? I'm not really sure how to make it work properly. I would probably do something like this #include <date.au3> $bday = StringFormat("%4d/07/13",@YEAR) $happydone = false $something = True while $something if _DateDiff('d',@YEAR & "/" & @MON & "/" & @MDAY ,$bday) = 0 and not $happydone Then msgbox(0,"smile!","It's your birthday") $happydone = True EndIf WEnd Not tested, just an idea. Edited December 1, 2006 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now