VoxCommando

VoxNastics (User Guides and Mods) => Tips and Tricks => Topic started by: Haddood on October 03, 2014, 06:45:46 PM

Title: Integrating windows task scheduler with VC for reminders and events
Post by: Haddood on October 03, 2014, 06:45:46 PM
windows task scheduler is a very powerful part of windows and it can be integrated with VC to create reminders and events that trigger various actions without polling.

tasks can be added to WTS with command line and the task shouldn't be very hard ... here is a reference http://technet.microsoft.com/en-ca/library/cc772785(v=ws.10).aspx#BKMK_create

VC tasks can be stored in a VC folder ...

command can be
remind me at (time) on (date) to (do something)
create an event (event name) at (time) on (date)
create an event (event name) every day at (time)
create an event (event name) every day at (time) on (date)
etc.

delete commands
and modify ...

if anybody feeling to get hands dirty will be great ... on my side it is on agenda but not very soon ...

or even this can be converted into a plugin which would make life much easier
Title: Re: Integrating windows task schedueler with VC for remiders and events
Post by: Haddood on October 05, 2014, 02:12:45 AM
Had some time today and I decided to work on this a bit... here is the core function that creates the WTS new task ...
it should be called by commands to create reminders, alarms and other schedules ...

it takes 4 payloads .... (see description in the command)  to test it see the second command ...
Sub folders can be created by passing them along with task name in payload 1

{1} = alarms\alarm 1 will create subfolder called alarms and create a task called alarm 1

Edit: Command has been revised, changed the sequence of payloads passed to tsksch.exe in order to make payload(s) passed with VC event optional (if no payload specified to be passed with VC event, event will trigger with payload 1 = nill) ... reset lastresult to avoid reporting false success.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.0.3-->
<command id="604" name="Create Windows Task" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="All tasks will be created in iHome\VC&#xD;&#xA;{1} Windows Task Name &#xD;&#xA;{2} schedule  ( ex: weekly /d WED see http://technet.microsoft.com/en-ca/library/cc772785(v=ws.10).aspx#BKMK_create)&#xD;&#xA;{3} VC event name &#xD;&#xA;{4} payload(s) to pass (multiple payload must be passed as one string, &amp; signs must be quoted like in PL 1&quot;&amp;&quot;&quot;&amp;&quot;PL 2)  - optional&#xD;&#xA;">
  <action>
    <cmdType>Launch.Capture</cmdType>
    <params>
      <param>C:\Windows\System32\schtasks.exe</param>
      <param>/create /tn "\iHome\VC\{1}" /sc {2} /tr "\"{Path.VC}\VoxCommando.exe\" -33000 \"VC.TriggerEvent"&amp;""&amp;"WTS.{3}"&amp;""&amp;"{4}\""</param>
      <param>True</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="True">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>{LastResult}&amp;&amp;SUCCESS</ifParams>
    <then>
      <action>
        <cmdType>VcAdvanced.Log</cmdType>
        <params>
          <param>task creation failed</param>
          <param>{LastResult}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>VcAdvanced.Log</cmdType>
        <params>
          <param>Success</param>
          <param>{LastResult}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <params />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>WTS.Create</event>
</command>

----------------------------- command to test task creation ( LCB allow 3 payloads and command need 4) -----------------------------

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.0.3-->
<command id="629" name="test task create" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>VC.TriggerEvent</cmdType>
    <params>
      <param>WTS.Create</param>
      <param>Alarm\6</param>
      <param>weekly /d WED</param>
      <param>Alarm</param>
      <param>PL 1"&amp;""&amp;"PL 2</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>
Title: Re: Integrating windows task scheduler with VC for remiders and events
Post by: jitterjames on October 05, 2014, 08:46:37 AM
To add more parameters to an action just use the parameter helper.

http://voxcommando.com/mediawiki/index.php?title=Parameter_Helper
Title: Re: Integrating windows task scheduler with VC for remiders and events
Post by: jitterjames on October 05, 2014, 08:53:12 AM
Works great. Thanks Hadood!  :hugs
Title: Re: Integrating windows task scheduler with VC for reminders and events
Post by: Haddood on October 08, 2014, 06:07:50 AM
here is the first application for windows task scheduler ... needs the revised command in post 1

it is a command that sets an alarm event by saying: set an alarm at time or wake me up at time ... time can be 12/24h format or even military   8) 8) - if am/pm not specified 9 will mean 9:00 am
(not if you use military it will set the event correctly but the feedback -TTS- won't say hundred or hour)...

replace trigger feedback with TTS or anything else as you see fit ...

the command will not produce the alarm sound. it will only set a task to trigger an event at the specified time ... create your own alarm sound command ... will be cool if someone do it with snooze function (let me sleep another 10 minutes)

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.0.3-->
<command id="670" name="Alarm" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)&lt;(B)</ifType>
    <ifParams>{1}&amp;&amp;10</ifParams>
    <then>
      <action>
        <cmdType>Results.SetVar</cmdType>
        <params>
          <param>hour</param>
          <param>0{1}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>Results.SetVar</cmdType>
        <params>
          <param>hour</param>
          <param>{1}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>{2} {3}&amp;&amp;PM</ifParams>
    <then>
      <action>
        <cmdType>PY.ExecString</cmdType>
        <params>
          <param>result = {1} +12</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>Results.SetVar</cmdType>
        <params>
          <param>hour</param>
          <param>{LastResult}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)==(B)</ifType>
    <ifParams>{#P}&amp;&amp;1</ifParams>
    <then>
      <action>
        <cmdType>Results.SetVar</cmdType>
        <params>
          <param>minute</param>
          <param>00</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>AM PM&amp;&amp;{2}</ifParams>
    <then>
      <action>
        <cmdType>Results.SetVar</cmdType>
        <params>
          <param>minute</param>
          <param>00</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)&lt;(B)</ifType>
    <ifParams>{2}&amp;&amp;10</ifParams>
    <then>
      <action>
        <cmdType>Results.SetVar</cmdType>
        <params>
          <param>minute</param>
          <param>0{2}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>{LastSpoken}&amp;&amp;wake me up</ifParams>
    <then>
      <action>
        <cmdType>VC.TriggerEvent</cmdType>
        <params>
          <param>WTS.Create</param>
          <param>Alarm\Wakeup{DtCustom.MMddHHmm}</param>
          <param>once /st {Var.hour}:{Var.minute}</param>
          <param>Alarm</param>
          <param>alarm1.wav</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>VC.TriggerEvent</cmdType>
        <params>
          <param>feedback </param>
          <param>I will make sure to wake you up at {1}:{2} {3}</param>
          <param>2</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>VC.TriggerEvent</cmdType>
        <params>
          <param>WTS.Create</param>
          <param>Alarm\alarm{DtCustom.MMddHHmm}</param>
          <param>once /st {Var.hour}:{Var.minute}</param>
          <param>Alarm</param>
          <param>alarm2.wav</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>VC.TriggerEvent</cmdType>
        <params>
          <param>feedback </param>
          <param>I set up an alarm at {1}:{2} {3}</param>
          <param>2</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <phrase>set an alarm, wake me up</phrase>
  <phrase>at</phrase>
  <payloadRange>1,23</payloadRange>
  <phrase optional="true">O, hundred</phrase>
  <payloadRange optional="true">1,59</payloadRange>
  <phrase optional="true">o'clock, hour</phrase>
  <payloadList optional="true">AM, PM</payloadList>
</command>
Title: Re: Integrating windows task scheduler with VC for reminders and events
Post by: outlaw on July 25, 2015, 09:36:04 PM
hi im still a newbie here  ;D but I have been trying to setup tts for this xml so vc will say what time it is setting the alarm for but no such luck. sorry but could someone maybe help with this issue?
Title: Re: Integrating windows task scheduler with VC for reminders and events
Post by: nime5ter on July 25, 2015, 10:01:30 PM
What have you tried so far? If you post the xml for the command(s) you revised or tried to make without luck so far, it will be easier to assist.

Title: Re: Integrating windows task scheduler with VC for reminders and events
Post by: JonPeyton on October 30, 2015, 08:19:27 PM
works well thank you!