Page 2 of 3
Re: Event when TV is connected - possible?
Posted: Fri Jan 20, 2012 5:54 am
by Livin
eatmeimadanish wrote:The HDMI CEC adapter from either pulse 8 or RCAware will tell you when a device comes on, and let you query a device status.
yup... but not worth spending $50 for me. When they are $20, I'm in.
Re: Event when TV is connected - possible?
Posted: Mon Jan 30, 2012 4:18 am
by hotbuddha
My LG TV actually causes the event to be fired when turned on/off, but I am wired directly from the TV to the PC with no router between as in your setup with the amp. I would check the configuration of you amp to see if there is a setting for HDMI power pass through or something like that. Some receivers provide continuous pass through of the signal even when powered off, if you turn that setting off, perhaps when there is no signal on that cable to the monitor the code I gave you would fire the event (as it does when the cable is directly between the PC and TV).
Re: Event when TV is connected - possible?
Posted: Tue Sep 18, 2012 4:56 am
by snack
My Vizio 47" TV that is connected to the computer via HDMI gives this event when I turn on the TV:
System.DeviceRemoved [u'\\\\?\\DISPLAY#VIZ0033#4&1117d43&0&UID52628224#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}']
System.DeviceAttached [u'\\\\?\\DISPLAY#VIZ0033#4&1117d43&0&UID52628224#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}']
Can EventGhost trigger on this so I can run a batch file to kill an app and restart it? This particular app is configured to run on the secondary monitor (TV). When the TV is powered off, it stays on the secondary monitor. When I power back on, the app reappears on my main monitor.
Re: Event when TV is connected - possible?
Posted: Tue Sep 18, 2012 3:57 pm
by Livin
snack wrote:My Vizio 47" TV that is connected to the computer via HDMI gives this event when I turn on the TV:
System.DeviceRemoved [u'\\\\?\\DISPLAY#VIZ0033#4&1117d43&0&UID52628224#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}']
System.DeviceAttached [u'\\\\?\\DISPLAY#VIZ0033#4&1117d43&0&UID52628224#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}']
Can EventGhost trigger on this so I can run a batch file to kill an app and restart it? This particular app is configured to run on the secondary monitor (TV). When the TV is powered off, it stays on the secondary monitor. When I power back on, the app reappears on my main monitor.
Yes
But you don't need a batch file... EG can do everything itself. Read the Wiki and/or just browse the Actions and things will become obvious like: Close Application, Launch Application, etc
Re: Event when TV is connected - possible?
Posted: Wed Sep 19, 2012 1:59 am
by snack
I read the wikis before I posted. I do not find anything about System.DeviceAttached. I know how to create an event for it. What I am requesting is to specify the string the follows the System.DeviceAttached so the event is activated on that particular device being attached. Without this parameter, then many devices (e.g. USB flash drive) will activate the event.
Re: Event when TV is connected - possible?
Posted: Wed Sep 19, 2012 2:13 am
by Livin
snack wrote:I read the wikis before I posted. I do not find anything about System.DeviceAttached. I know how to create an event for it. What I am requesting is to specify the string the follows the System.DeviceAttached so the event is activated on that particular device being attached. Without this parameter, then many devices (e.g. USB flash drive) will activate the event.
As documented...
http://www.eventghost.org/docs/short_ma ... -to-macros
Re: Event when TV is connected - possible?
Posted: Wed Sep 19, 2012 2:24 am
by snack
Read my post and visit your link. It does not say anything about how to specify a string for System.DeviceAttached. I played with EventGhost before posting, and it does not specifying a parameter for System.DeviceAttached. If I am wrong, then please tell me step by step how to do so.
Re: Event when TV is connected - possible?
Posted: Wed Sep 19, 2012 3:44 am
by Livin
You are missing the point... Drag and drop the event from the log to the macro. Forget about creating anything.
Re: Event when TV is connected - possible?
Posted: Wed Sep 19, 2012 3:59 am
by jonib
snack wrote:I played with EventGhost before posting, and it does not specifying a parameter for System.DeviceAttached.
You need to read the "
eg.event.payload" variable to get to the extra data in the event.
jonib
Re: Event when TV is connected - possible?
Posted: Wed Sep 19, 2012 5:28 am
by snack
Livin wrote:You are missing the point... Drag and drop the event from the log to the macro. Forget about creating anything.
Do you know what happens when I drag and drop this from the log window to a macro?
System.DeviceAttached [u'\\\\?\\DISPLAY#VIZ0033#4&1117d43&0&UID52628224#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}']
It creates an event called System.DeviceAttached, and it matches that on any System.DeviceAttached [u'...........] that occurs, such as my tv being turned on, a USB flash drive being attached, etc. because it does not match on the parameter string. Have you ever tried a drag and drop of a System.DeviceAttached from the log window?
Back to my original request: it would be nice if System.DeviceAttached took a parameter string as input, and matched on that as well, so one can create a System.DeviceAttached event for specific devices.
Re: Event when TV is connected - possible?
Posted: Wed Sep 19, 2012 5:55 am
by krambriw
As was explained above, it is not wrong to drag & drop the event to a macro, that's a start. Then, as jonib writes, you need to add a python script to the macro that captures the content of the payload and makes something out of it, eventually creates a new event or jumps to another macro, whatever is useful for your application.
There are tons of samples in this forum how to capture the payload from an event, write scripts and how to create a new event.
BR Walter
Re: Event when TV is connected - possible?
Posted: Wed Sep 19, 2012 6:18 am
by Livin
When I did this in the past (and I just tested, it works) all I did to get the full string (payload) was to highlight the log event, copy (ctrl-c), and then paste it into the macro trigger (you must right-click / config). Then the entire payload came over... and it would trigger events fine for me.
I ditched the payload method, don't remember why, but I then moved to a Macro using script with Monitor # enumeration (Macro triggered by Main.OnInit)...
Code: Select all
from threading import Thread, Event
from win32api import EnumDisplayMonitors
class MyThread(Thread):
def __init__(self):
Thread.__init__(self, name = 'CheckTV_Thread')
self.event = Event()
self.tv = False
def run(self):
while True:
mons = EnumDisplayMonitors()
if len(mons) > 1:
if not self.tv:
self.tv = True
print "TV Connected"
eg.TriggerEvent("Connected", prefix = "TV")
else:
if self.tv:
self.tv = False
print "TV Not Connected"
eg.TriggerEvent("Disconnected", prefix = "TV")
self.event.wait(5)
self.event.clear()
mt = MyThread()
mt.start()
Re: Event when TV is connected - possible?
Posted: Wed Sep 19, 2012 2:45 pm
by krambriw
Here is a simple thing just to get you going. Create a macro with a python script and drag & drop the two events for 'Removed' and 'Attached' to the macro you just defined. Then edit the script as below (copy & paste).
Every time it is getting removed or attached, you will get new events for it like My_Vizio_47.Removed or My_Vizio_47.Attached.
Use those new events to trigger other actions to close or open programs etc.
Best regards, Walter
Code: Select all
device = 'DISPLAY#VIZ0033#4&1117d43&0&UID52628224#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}'
eg.event.payload_copy = eg.event.payload
eg.event.suffix_copy = eg.event.suffix
if eg.event.payload_copy.find(device) != -1:
if eg.event.suffix_copy.find('Removed') != -1:
eg.TriggerEvent('Removed', prefix = 'My_Vizio_47')
if eg.event.suffix_copy.find('Attached') != -1:
eg.TriggerEvent('Attached', prefix = 'My_Vizio_47')
Re: Event when TV is connected - possible?
Posted: Wed Sep 19, 2012 3:25 pm
by Livin
I think I remember why I do not use the payload method... My TV is connected to my receiver, not direct to my HTPC. In this case, EG will only see when the receiver is connected, thus, not when the TV itself is actually turned on/connected. I 'think' the EnumDisplay method worked better in this case, but I'm not sure. I'll test again later today and also test Walters code (I'm sure it works, just want to see if there is a functional difference)
Re: Event when TV is connected - possible?
Posted: Wed Sep 26, 2012 5:55 am
by blaher
Livin wrote: (I'm sure it works, just want to see if there is a functional difference)
I couldn't get Walter's code to work, even after replacing the device ID. I'm not sure what I've done wrong:
15:14:59 Traceback (most recent call last):
15:14:59 Python script "1", line 5, in <module>
15:14:59 if eg.event.payload_copy.find(device) != -1:
15:14:59 AttributeError: 'list' object has no attribute 'find'
But below you can see the difference between using the device attached trigger, and Livin's script:
http://i.imgur.com/37dvo.gif
When I turn on my receiver, it attaches, removes and attaches again, as my monitor blanks for a second and locks on. Livin's script just shows connected, albeit a a few seconds later.
Another thing to note is that when you use the full string, e.g., System.DeviceRemoved [u'\\\\?\\DISPLAY#ONK089B#5&13c1ef77&1&UID259#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}'] it doesn't trigger an event as you can see by the 'test' OSD on my screenshot.
Also when you first initialise EventGhost and use Main.OnInit with Livin's script, if the monitor is disconnected you won't get an event of TV.Disconnected, but if the monitor is on when you first start EventGhost, you do get a TV.Connected event.