Page 1 of 1

Help needed with Start/Stop plugin from a python script

Posted: Sun Mar 08, 2009 2:44 pm
by olddog
Hi all,

I have a python script which controls a number of remote plugins, these are based on VMC controller and control Windows7 Media Center and it's Extenders.

However there are times i need to control then enable/disable of the plugin from within a script, after reading and decoding lots of other source i have tried :-

eg.plugins.EventGhost.EnableItem("VMCControl")
but i get a string parameter error and missing target.

Traceback (most recent call last):
Python script "96", line 17, in <module>
eg.plugins.EventGhost.EnableItem("MCXControl4")
File "C:\Program Files\EventGhost\plugins\EventGhost\__init__.py", line 134, in __call__
AttributeError: 'str' object has no attribute 'target'


Is it possible that someone could point me in the right direction.

Before you ask, yes i could define mutilple events and actions and use the Enable/Disable Item option within the plugin tree or XML file, i am specifically enquiring about doing this from within a python script.

Thank you in advance for any help.

Regards

Nigel

Re: Help needed with Start/Stop plugin from a python script

Posted: Sun Mar 08, 2009 11:57 pm
by jsonnabend
I think the parameter needs to be the ID attribute of the node you are trying to enable/disable (and it needs to be cast as an XMLIdLink). For example:

Code: Select all

eg.plugins.EventGhost.EnableItem(XmlIdLink(28))
- Jeff

Re: Help needed with Start/Stop plugin from a python script

Posted: Wed Mar 11, 2009 11:51 pm
by olddog
Thanks for the reply Jeff,

I tried as you advised but just get the following message;-

23:49:10 Traceback (most recent call last):
23:49:10 Python script "18", line 1, in <module>
23:49:10 eg.plugins.EventGhost.DisableItem(XmlIdLink(4))
23:49:10 NameError: name 'XmlIdLink' is not defined


Thanks for your help though.

Regards

Nigel

Re: Help needed with Start/Stop plugin from a python script

Posted: Thu Mar 12, 2009 3:04 pm
by jsonnabend
I see the same problem here. I've played around with this some, but I can't figure out a work around. Perhaps Bitmonster will chime in.

- Jeff

Re: Help needed with Start/Stop plugin from a python script

Posted: Thu Oct 06, 2011 8:30 pm
by tlgwat
For what it's worth - I've found a workaround.

I wanted to be able to toggle from a program, to the mouse, and then back to the program without having to push another button.
First I initialized a variable using PythonCommand in Autostart, mouse=0
I set a trigger on the mouse button to execute a Python script

Code: Select all

from os import path
if eg.globals.mouse == 1:
    eg.TriggerEvent("TurnMouseOff")
else:
    eg.TriggerEvent("TurnMouseOn")
Next I set up event handlers for those events:
TurnMouseOn enables exclusive on the mouse emulation context folder
I show OSD: Mouse Mode: ON
and set using Python command mouse =1

TurnMouseOff executes a Python Script:

Code: Select all

from os import path
if eg.globals.programControl == "MCE":
    eg.TriggerEvent("enableEx:MCE")
elif eg.globals.programControl == "XBMC":
    eg.TriggerEvent("enableEx:XBMC")
elif eg.globals.programControl == "BeyondTV":
    eg.TriggerEvent("enableEx:BeyondTV")
else:
    eg.TriggerEvent("enableEx:Keyboard")
next, set mouse=0 using Python Command, and
show OSD Mouse Mode: OFF

I created event handlers for each of the above, e.g. enableEx:MCE. All those do is Enable exclusive for each respective item.
"programControl" is a variable I set when the application is launched, e.g. programControl = "MCE" when MediaCenter is launched.

I'm considering setting programControl to "0" if the application is destroyed.