I use a script function to create a timed event.
However this event as created will trigger at a specific time. Instead I want to trigger if it's past this time. How can I do this?
This is what i use now.
Code:
Sub SetAudioEvent(ByVal TriggerTime As Integer, ByVal Location As String, ByVal strActionScriptName As String, ByVal strSub As String, ByVal strParms As String) Dim EvRef As Integer Dim OldEvRef As Integer Dim EvTime As Date Dim strTimerName As String strTimerName = Location + " " + VOLUME 'Delete event if already exists oldEvRef = hs.GetEventRefByName(strTimerName) If oldEvRef > 0 Then 'event does exist hs.DeleteEventByRef(oldEvRef) End If ' Create the new Event EvRef = hs.NewEventEx(strTimerName, AUDIOSYSTEM, "") ' Enable the Event hs.EnableEventByRef(EvRef) ' Set the trigger time dim d as Date = new DateTime(1, 1, 1, DateTime.Now.Hour,DateTime.Now.Minute, DateTime.Now.Second) EVTime = DateAdd("s", TriggerTime, d) hs.EventSetTimeTrigger(EvRef, EVTime) 'Delete the event after triggering hs.DeleteAfterTrigger_Set(EvRef) 'Script [OFF event] strParms = Location & ";" & EVENT_OFF & ";0" 'Time is a dummy value hs.AddActionRunScript(EvRef, strActionScriptname, "Main", strParms) End Sub