Author Topic: Fix - Launch - Focus - Restart Kodi, or other programs  (Read 1701 times)

0 Members and 1 Guest are viewing this topic.

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
Fix - Launch - Focus - Restart Kodi, or other programs
« on: July 19, 2016, 11:40:12 PM »
Here's a command that I made using the new Win Plugin Found in 2.2.2.1 / 2.2.2.2

Required Plugins
Win
DXInput


Fix Kodi group has two different commands:

Crash / Focus / Launch:

1.) looks for the "Kodi has Stopped Working" Window:
commercial photography locations

2.) if Successful it will focus the window and then use DXInput plugin to emulate "return" and then set an event timer for ten seconds to launch Kodi

3.) if not Successful it will look for Kodi

4.) if Successful it will Focus/bring to front kodi

5.) if not Successful it will launch Kodi

all with one voice command

Restart:

1.) Disconects from Kodi

2.) looks for Kodi

3.) Closes Kodi

4.) sets timer event to Launch Kodi in ten Seconds


Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.2.2-->
<commandGroup open="True" name="Fix Kodi" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="88" name="Crash / Focus / Launch" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{1}&amp;&amp;Restart</ifParams>
      <then>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Restarting Kodi, Please Wait</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>XJson.Disconnect</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Win.Find.ByName</cmdType>
          <params>
            <param>Kodi</param>
            <param>Kodi</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Win.Set.State</cmdType>
          <params>
            <param>Close</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.SetEventTimer</cmdType>
          <params>
            <param>10s</param>
            <param>Fix Kodi</param>
            <param>Focus</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.StopMacro</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>Win.Find.ByName</cmdType>
          <params>
            <param>Kodi</param>
            <param>#32770</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>LastActionSuccess</ifType>
      <ifParams>&amp;&amp;</ifParams>
      <then>
        <action>
          <cmdType>Win.Set.Focus</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>DxInput.KeyPress</cmdType>
          <params>
            <param>return</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.SetEventTimer</cmdType>
          <params>
            <param>10s</param>
            <param>Fix Kodi</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.StopMacro</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>Win.Find.ByName</cmdType>
          <params>
            <param>Kodi</param>
            <param>Kodi</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>LastActionSuccess</ifType>
      <ifParams>&amp;&amp;</ifParams>
      <then>
        <action>
          <cmdType>Win.Set.Focus</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Loading Kodi, Please Wait</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Launch</cmdType>
          <params>
            <param>C:\Program Files (x86)\Kodi\Kodi.exe</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <phrase>Fix, Launch, Focus</phrase>
    <phrase>Kodi</phrase>
    <event>Fix Kodi</event>
  </command>
  <command id="89" name="Restart" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>Restarting Kodi, Please Wait</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>XJson.Disconnect</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Win.Find.ByName</cmdType>
      <params>
        <param>Kodi</param>
        <param>Kodi</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Win.Set.State</cmdType>
      <params>
        <param>Close</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.SetEventTimer</cmdType>
      <params>
        <param>10s</param>
        <param>Fix Kodi</param>
        <param>Focus</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Restart Kodi</phrase>
    <event>Restart Kodi</event>
  </command>
</commandGroup>

this could be changed to work with other programs as well, you would just need to get the window information using the new win plugin

Thanks for the new plugin jitterjames
« Last Edit: August 28, 2017, 08:56:13 PM by PegLegTV »