'---------------------------------------------------------------------------- ' ' SampleCreateAlarm.vbs ' ' This VBScript demonstrates the powerful capabilities available ' when controlling Alarm++ through automation. ' ' It creates a simple alarm, as specified by the passed parameters. ' There are other alarm properties that can be set, such as the snooze ' interval. Please see the help topic "Automation" for details. ' ' ' Arguments: ' alarm name ' message ' date (mm/dd/yyyy or "dd month yyyy") ' time (hh:mm) ' repeat frequency (e.g., "5" for "every 5 weeks") ' repeat interval (minutes, hours, days, weeks, months, years) ' duration (i.e., a number of events or "forever") ' ' Examples: ' ' cscript CreateAlarm.vbs "Friend's birthday" "Don't forget Pauline's birthday!" "16 December 2010" "09:00" 1 years forever ' cscript CreateAlarm.vbs "Organizational meetings" "Don't forget the ten organizational meetings." "5 Jan 2011" "14:00" 2 weeks 10 ' '---------------------------------------------------------------------------- ' ' (c) 2003 12noon, Stefan K. S. Tucker. All Rights Reserved. ' ' You have a royalty-free right to use, modify, reproduce and distribute ' the Sample Application Files (and/or any modified version) in any way you ' find useful, provided that you agree that 12noon has no warranty, ' obligations or liability for any Sample Application Files. ' '---------------------------------------------------------------------------- option explicit ' ' If the bDebug variable is true, the script displays debugging information ' dim bDebug bDebug = false 'dim iValue 'iValue = MsgBox("This script creates a new alarm in the file Alarm++ currently has open. Do you want to continue?", _ ' vbYesNo + vbExclamation, "12noon") 'if iValue = vbNo then ' wscript.Quit(1) 'End If if (bDebug) then dim arg for each arg in wscript.Arguments wscript.Echo arg next end if if (wscript.Arguments.Count <> 7) then call MsgBox("This script requires seven arguments: name, message, date, time, repeat frequency, repeat interval, and the number of events. Please see the comments in this script file for details.", _ vbOKOnly + vbExclamation, "12noon") wscript.Quit(2) end if ' ' Read in the arguments ' dim strName, strMessage, strDate, strTime, iRepeatFrequency, strRepeatInterval, iDuration strName = wscript.Arguments(0) strMessage = wscript.Arguments(1) strDate = wscript.Arguments(2) strTime = wscript.Arguments(3) iRepeatFrequency = wscript.Arguments(4) strRepeatInterval = wscript.Arguments(5) if (wscript.Arguments(6) = "forever") then iDuration = 0 else iDuration = wscript.Arguments(6) end if dim app 'as AlarmPlusPlus.Application set app = GetObject(, "12noon.Alarm.Document") ' returns the Alarm++ Application object ' if this fails, the Alarm++ application is not running. if (app is nothing) then call MsgBox("Unable to find a running instance of Alarm++. Alarm++ must be running when you use this script.", vbOKOnly + vbExclamation, "12noon") wscript.Quit(3) else dim doc 'as AlarmPlusPlus.Document set doc = app.ActiveDocument app.Visible = True dim alarms 'as AlarmPlusPlus.Alarms set alarms = doc.Alarms dim alarm set alarm = alarms.Add ' Change name and message alarm.Name = strName alarm.Message = strMessage ' ' A new alarm is initially disabled, ' so we have to give it a number of events or forever ' if (iDuration = 0) then alarm.RepeatForever = true else alarm.NumberOfEvents = iDuration end if ' ' Set date/time of next event. ' alarm.Date = DateValue(strDate) alarm.Time = TimeValue(strTime) ' ' Set repeat interval ' alarm.RepeatIntervalNumber = iRepeatFrequency if (strRepeatInterval = "minutes") then alarm.RepeatIntervalMinutes = True elseif (strRepeatInterval = "hours") then alarm.RepeatIntervalHours = True elseif (strRepeatInterval = "days") then alarm.RepeatIntervalDays = True elseif (strRepeatInterval = "weeks") then alarm.RepeatIntervalWeeks = True elseif (strRepeatInterval = "months") then alarm.RepeatIntervalMonths = True elseif (strRepeatInterval = "years") then alarm.RepeatIntervalYears = True else call MsgBox("Unknown repeat interval '" + strRepeatInterval + "'. Please use 'minutes,' 'hours,' 'days,' 'weeks,' 'months,' or 'years.' (Using minutes for this alarm.) Please see the comments in this script file for details.", _ vbOKOnly + vbExclamation, "12noon") alarm.RepeatIntervalDays = True end if ' ' ' ' Set snooze interval to 30 minutes ' ' ' alarm.SnoozeIntervalNumber = 30 ' alarm.SnoozeIntervalMinutes = True ' ' This code can help debug the script. ' Just set bDebug to true. ' if (bDebug) then wscript.Echo "Name = " & doc.Name ' output: "Alarm++" wscript.Echo "FullName = " & doc.FullName ' path to alarm.exe ' Show new name and message wscript.Echo "New: name = " & alarm.Name & ", msg = " & alarm.Message ' Show default event date/time wscript.Echo "Default: date/time = " & alarm.Date ' Show event date/time wscript.Echo "New: date/time = " & alarm.Date call DisplayRepeatInterval call DisplaySnoozeInterval end if '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' Tell the view to update itself. This is because an alarm ' doesn't automatically update the view when it's added or ' changed. ' alarms.Refresh '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' Save the changes. ' doc.Save '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' Clean up ' set alarms = Nothing set doc = Nothing 'app.Quit set app = Nothing end if '--------------------------------------------------------------- ' ' DisplayRepeatInterval ' ' This routine is used to display information about the passed ' alarm's repeat interval. ' '--------------------------------------------------------------- sub DisplayRepeatInterval() if (alarm.RepeatIntervalMinutes) then wscript.Echo "Repeat Interval: every " & alarm.RepeatIntervalNumber & " minutes" elseif (alarm.RepeatIntervalHours) then wscript.Echo "Repeat Interval: every " & alarm.RepeatIntervalNumber & " hours" elseif (alarm.RepeatIntervalDays) then wscript.Echo "Repeat Interval: every " & alarm.RepeatIntervalNumber & " days" elseif (alarm.RepeatIntervalWeeks) then wscript.Echo "Repeat Interval: every " & alarm.RepeatIntervalNumber & " weeks" elseif (alarm.RepeatIntervalMonths) then wscript.Echo "Repeat Interval: every " & alarm.RepeatIntervalNumber & " months" elseif (alarm.RepeatIntervalYears) then wscript.Echo "Repeat Interval: every " & alarm.RepeatIntervalNumber & " years" end if end sub '--------------------------------------------------------------- ' ' DisplaySnoozeInterval ' ' This routine is used to display information about the passed ' alarm's snooze interval. ' '--------------------------------------------------------------- sub DisplaySnoozeInterval() if (alarm.SnoozeIntervalMinutes) then wscript.Echo "Snooze Interval: every " & alarm.SnoozeIntervalNumber & " minutes" elseif (alarm.SnoozeIntervalHours) then wscript.Echo "Snooze Interval: every " & alarm.SnoozeIntervalNumber & " hours" elseif (alarm.SnoozeIntervalDays) then wscript.Echo "Snooze Interval: every " & alarm.SnoozeIntervalNumber & " days" end if end sub