Page 1 of 3
Event when TV is connected - possible?
Posted: Fri Oct 15, 2010 6:48 am
by Havremunken
Hi there,
Using EventGhost 0.3.7.r1462 on Windows 7 Enterprise, updated regularly with Windows Update.
I have a normal computer monitor connected to my PC. There is also a DVI cable connected to the receiver of my home cinema setup. Windows is set up in such a way that when the receiver is switched to the "HTPC" channel, the TV monitor object comes alive in Windows (it is not listed as connected otherwise), and it is now the primary screen - where the taskbar etc. resides. I can then start XBMC to watch stuff. All good.
However, what I would really love to do, is to have EventGhost give me an event when the receiver/TV monitor is "connected", so that I can automatically launch XBMC - that means I could control everything from the living room and not have to fiddle with stuff to get into the OSD. This would be a big help to my fiancee who is not quite as technical in nature as I am.
However, when I switch the receiver to the HTPC channel, no event is displayed in the log of EventGhost. I did not check the box to log only events handled by the system.
Is it possible to detect some kind of even for this? Either that another monitor suddenly exists in the system, or that the "primary screen" is now a different screen than it used to be.
Also, if that is possible, the opposite event would also be nice, so I can shut down XBMC once the receiver goes to another display unit.
If you need any further info, let me know. I would be very happy to solve this somehow.

Re: Event when TV is connected - possible?
Posted: Fri Oct 15, 2010 8:22 am
by Pako
You can copy and paste the following code into the eventGhost tree and it should work automatically (after save configuration, close and restart EventGhost).
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1462">
<Folder Name="Check TV" Expanded="True">
<Macro Name="Check TV" Expanded="True">
<Event Name="Main.OnInit" />
<Action>
EventGhost.PythonScript(u'from threading import Thread, Event\nfrom win32api import EnumDisplayMonitors\nclass MyThread(Thread):\n def __init__(self):\n Thread.__init__(self, name = \'CheckTV_Thread\')\n self.event = Event()\n self.tv = False\n \n def run(self):\n while True:\n mons = EnumDisplayMonitors()\n if len(mons) > 1:\n if not self.tv:\n self.tv = True\n eg.TriggerEvent("Connected", prefix = "TV")\n else:\n if self.tv:\n self.tv = False\n eg.TriggerEvent("Disonnected", prefix = "TV")\n self.event.wait(5)\n self.event.clear()\n \n\nmt = MyThread()\nmt.start()\n')
</Action>
</Macro>
</Folder>
</EventGhost>
Pako
Re: Event when TV is connected - possible?
Posted: Fri Oct 15, 2010 4:47 pm
by Havremunken
Worked like a charm - much appreciated!

Re: Event when TV is connected - possible?
Posted: Fri Jan 21, 2011 3:22 pm
by zian
I have looked and looked...
Is there a simple code for EG to know what monitor is active?
Right now I switch between monitors (32" and 19" both different resolutions) with emulated key strokes on the remote (Win key + P then a left or right) and that fires enable/disable of two separate folders I have for each monitor. In those folders I have restore icon batch files (per mon resolutions) & start/stop magnify.exe and a few others)...
but...
If I actually use the keyboard to switch monitors and not my X10 remote EG wont disable/enable those separate monitor folders.
a code for telling EG if Mon 1 or 2 is active would be sweet.
Does this make sense?
thanks.
Newest EG
Win7
X10 Firefly
Re: Event when TV is connected - possible?
Posted: Mon Jul 04, 2011 4:29 pm
by Livin
Pako,
It looks like your code is looks every 5 seconds to see if more than one display is connected. This works, of course, but does not allow for granular control. It would be nice to specify the actual display.
When I turn on the locally connected LCD, EGs log shows...
Code: Select all
System.DeviceAttached [u'\\\\?\\USB#VID_05A9&PID_2656#6&124eb89e&0&1#{a5dcbf10-6530-11d2-901f-00c04fb951ed}']
System.DeviceAttached [u'\\\\?\\USB#VID_1926&PID_0064#7&704e306&0&1#{a5dcbf10-6530-11d2-901f-00c04fb951ed}']
System.DeviceAttached [u'\\\\?\\HID#VID_1926&PID_0064&MI_00&Col01#9&2d214944&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}']
System.DeviceAttached [u'\\\\?\\HID#VID_1926&PID_0064&MI_00&Col04#9&2d214944&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}']
System.DeviceAttached [u'\\\\?\\HID#VID_1926&PID_0064&MI_00&Col05#9&2d214944&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030}']
System.DeviceAttached [u'\\\\?\\HID#VID_1926&PID_0064&MI_00&Col06#9&2d214944&0&0005#{4d1e55b2-f16f-11cf-88cb-001111000030}']
System.DeviceAttached [u'\\\\?\\HID#VID_1926&PID_0064&MI_00&Col07#9&2d214944&0&0006#{4d1e55b2-f16f-11cf-88cb-001111000030}']
System.DeviceAttached [u'\\\\?\\HID#VID_1926&PID_0064&MI_01#9&94a0b82&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}']
System.DeviceAttached [u'\\\\?\\HID#VID_1926&PID_0064&MI_00&Col02#9&2d214944&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}']
System.DeviceAttached [u'\\\\?\\HID#VID_1926&PID_0064&MI_00&Col03#9&2d214944&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}']
When I connect via remote desktop EGs log shows...
Code: Select all
System.RemoteDisconnect [u'ha']
System.RemoteConnect [u'']
System.RemoteDisconnect [u'']
System.RemoteConnect [u'ha']
Using these we can specifically target a display to run specific events - this is the goal so people can have a single system (or remote systems) trigger events based on the specific display connected.
We still may need a general trigger if more than N displays is connected, or a display using a specific order/number, for items that do not report properly.
Could you make a plug-in to allow the user this level of control?
Re: Event when TV is connected - possible?
Posted: Tue Jul 05, 2011 6:35 am
by Pako
Livin wrote:Could you make a plug-in to allow the user this level of control?
I'm afraid that I misunderstood your idea.
You can write something understandable how such a plugin should work and what would be the result of his work?
Pako
Re: Event when TV is connected - possible?
Posted: Tue Jul 05, 2011 4:28 pm
by Livin
My thoughts for a plugin below... let me know what you think.
I'm thinking it should work like "Find Window" - but would be "Find Display"
*Features*
User to specify 'how' EG to finds Display(s)
... specific # (example: exactly 3 displays connected)
... less than (example: less than 2 displays connected)
... greater than (example: more than 3 displays connected)
... specific display # connected (example: display #4 is connected)
... specific display # not connected (example: display #4 is NOT connected)
... specific HID info, or set of infos ---- VID_1926&PID_0064&MI_00&Col01#9&2d214944&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
Actions EG to take when conditions above met, or not met
... same as current Find Window plugin (stop macro, etc)
Re: Event when TV is connected - possible?
Posted: Wed Jul 06, 2011 9:44 am
by Pako
Yes, now I understand.
I can not promise anything.
But it is possible that sometime in the future if not I'll have something to do, I'll try.
Pako
Re: Event when TV is connected - possible?
Posted: Thu Jul 07, 2011 6:15 pm
by Livin
If you could that would be great.
btw... do you have coding experience in other languages?
Re: Event when TV is connected - possible?
Posted: Sat Jan 14, 2012 5:11 am
by hotbuddha
Here you go, a bit quick and dirty for now but very simple to add to existing EG code. This worked for my Windows 7 x64 HTPC with a LG HDTV and I imagine should work for Vista and above with any display (let's hope works with XP/2000 or at least does not cause crashes and stuff).
This was created based on EG 4.1r1544 build files. Replace your old DeviceChangeNotifier.py file under EventGhost\plugins\System with this one and give a try. If this works for enough people I will request to have added to the next build. If it get's to that point then I personally will bind to these events from within the RCAware PC-CEC plugin to do TV hotplug detecting, which will call the already existing code which pulls the HDMI-CEC physical address from the EDID (right now the user has to press a button for that, will be nice when it is automatic

.
Re: Event when TV is connected - possible?
Posted: Wed Jan 18, 2012 3:08 am
by Livin
Tested it today... seems to detect the TV connection from my Onkyo receiver. Definitely does not detect the TV itself (I could turn the TV on/off without EG "seeing" it)... but, admittedly I'm not sure if any info would get changed/passed through on the Onkyo to do so.
Re: Event when TV is connected - possible?
Posted: Wed Jan 18, 2012 5:12 pm
by hotbuddha
Yes this is only for hot-plugging (connecting and disconnecting the cable to a device which is powered on at the time). For an HDTV on HDMI it might be that the only way to get real event based detection of power on/off is with HDMI-CEC. One last thing I will check for you though is that there may be a config change event that can be looked for using the same code I changed, assuming that power on/off generates such an event. I'll give that a try later and let you know.
Re: Event when TV is connected - possible?
Posted: Wed Jan 18, 2012 5:47 pm
by Livin
Cool... let me know what I need to test and/or get you logs/info for... I'm open most of the day today
I'd really like to be able to have EG detect the TV actually be on, then have it launch XBMC - this ensures XBMC will show on the TV, and not on the regular monitor. Right now I use a time delay and that is 80% accurate but sometimes...

Re: Event when TV is connected - possible?
Posted: Wed Jan 18, 2012 11:03 pm
by hotbuddha
Unfortunately the config change event only occurs for docking/undocking operations

I was not able to find anything else that would work either, especially not with a HDTV, as you know it does not even behave like an LCD monitor which at least sends/receives power signals over the cable (like when you put computer to sleep you can tell monitor to sleep).
Re: Event when TV is connected - possible?
Posted: Fri Jan 20, 2012 5:05 am
by eatmeimadanish
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.