Author Topic: New Variable {System.IP}  (Read 2131 times)

0 Members and 1 Guest are viewing this topic.

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
New Variable {System.IP}
« on: February 17, 2015, 03:53:05 PM »
I've been using AutoHotKey scripts that are converted to .exe files that are using the Run command to trigger events in VC to launch some stuff in xbmc so I can keep track of certain things like if PTVL is running, but the downside is that when those .exe files are ran they trigger the event on all systems which normally wouldn't be a big deal if you edit the script to trigger a different event for each computer,

but if you transferred a setup to another computer to work on it, then you would have the event being triggered twice.

so I was thinking a good away to stop this and also save us some time by not having to modify the event triggered for each computer
we could use a new variable {System.IP} then we could have the AutoHotKey script (or command line) carry the System Ip in payload 1
then we could use a logic block to compare {System.IP} to {1} to determine if that event should be triggered 


example:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.8-->
<command id="456" name="example " 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>{System.IP}&amp;&amp;{1}</ifParams>
    <then>
      <action>
        <cmdType>TTS.SpeakSync</cmdType>
        <params>
          <param>hello world</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <event>Hello World</event>
</command>


AutoHotKey script that could be used to pass the IP Address as {1}
Code: [Select]
Run VoxCommando.exe -33000 "VC.TriggerEvent&&Hello World&&%A_IPADDRESS1%

If this doesn't make sense let me know and I'll try to explain it better
also Im not sure if a variable for System IP can be made or not

Thanks
« Last Edit: February 17, 2015, 04:33:22 PM by PegLegTV »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: New Variable {System.IP}
« Reply #1 on: February 17, 2015, 05:04:12 PM »
Apologies in advance if I'm misunderstanding -- that's a lot to process.  ^-^

I guess what I'm wondering is how a variable {System.IP} would be different from simply using 127.0.0.1 or "localhost"?

Edit: I was thinking in terms of the System IP always referring to "this computer", but of course if you need to pass the actual IP value of "this computer" to another computer, 127.0.0.1 is not going to cut it. So maybe that was my confusion.
« Last Edit: February 17, 2015, 05:25:06 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
Re: New Variable {System.IP}
« Reply #2 on: February 17, 2015, 06:49:31 PM »
sorry for the confusion,

if I run this with AutoHotKey
Code: [Select]
Run VoxCommando.exe -33000 "VC.TriggerEvent&&Hello World&&%A_IPADDRESS1%
it triggers EVENT  "Hello world/{1}192.168.1.100"  and sends that to all VC in the network

%A_IPADDRESS1% = The IP of the computer that ran that script
so I was thinking that if we had a variable in VC that showed the IPv4 Address (same IP Like you would see if you ran ipconfig in CMD promt) so that way the IP's could be compared

It doesn't have to be {System.IP} I just thought using something different then 127.0.0.1 or LocalHost would make it less confusing for others


another example
use it on Living room pc ---{System.IP}=192.168.1.100 (IPv4 Address)
use it on Laptop---       {System.IP}=192.168.1.130 (IPv4 Address)


hope I explained it better this time

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: New Variable {System.IP}
« Reply #3 on: February 17, 2015, 06:54:51 PM »
OK, thanks for clarifying.

In the meantime, if it helps, you could use a bit of Python to generate a {var.myIP} variable on VC.Loaded (or whatever suits your needs).

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.7-->
<command id="278" name="get my IP" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>PY.ExecString</cmdType>
    <params>
      <param>import socket{CR}result=socket.gethostbyname(socket.gethostname())</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetVar</cmdType>
    <params>
      <param>myIP</param>
      <param>{LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>{var.myIP}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>VC.Loaded</event>
</command>

At least, that works for me!
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
Re: New Variable {System.IP}
« Reply #4 on: February 17, 2015, 07:00:12 PM »
Thanks That works great  ::banana

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: New Variable {System.IP}
« Reply #5 on: February 17, 2015, 07:04:14 PM »
Groovy.  :D
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)