Event on external monitor on/off

Got a good idea? You can suggest new features here.
Post Reply
Dzikerino
Posts: 6
Joined: Sat Aug 22, 2020 3:08 am

Event on external monitor on/off

Post by Dzikerino » Sat Aug 22, 2020 3:15 am

Hello,

I'm trying to hibernate my PC when external monitor (TV) is turned off, hence i need a way to detect this. I found a potential solution for that in this topic, but the most important part of this code being the use of EnumDisplayMonitors doesn't work for me for some reason. No matter how many monitors are connected and active, the length of the response is always 1. Do you guys have any ideas on how to make it work?

User avatar
kgschlosser
Site Admin
Posts: 5504
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Event on external monitor on/off

Post by kgschlosser » Sat Aug 22, 2020 8:17 am

I believe that EnumDisplayMonitors is going to return all the displays used on the desktop. This does not include mirrored displays, so if your desktop spans 3 monitors it will return 3 monitors. If your desktop spans 1 monitor and the second monitor is a mirror of the desktop EnumDisplayMonitors is only going to return the primary monitor and not the monitors showing the mirrored desktop.

There is an updated version of the System plugin that might provide you with an event when the display gets powered off.
viewtopic.php?p=46802#p46802

give that a shot and see if it works.

One other thing. you DO NOT want to use a System event to tell the computer to go into hibernation. You will use the System event to trigger another event and from that event you can start the hibernation process. This is because of how the Windows notification system works.
If you like the work I have been doing then feel free to Image

Dzikerino
Posts: 6
Joined: Sat Aug 22, 2020 3:08 am

Re: Event on external monitor on/off

Post by Dzikerino » Sat Aug 22, 2020 3:22 pm

Thank you for your response. If i'd extend screen over 2 monitors then i'll be able to get values from EnumDisplayMonitor - it's not a very convinient workaround but at least makes it feasible.

The system plugin you mentioned would be perfect but is not working for me (compilation error when i double click to install it).

Code: Select all

Compiling C:\ProgramData\EventGhost\plugins\System\Power\Notifier.py ...
SyntaxError: ('invalid syntax', ('UserPlugin\\Power\\Notifier.py', 118, 45, "        i: 'BatteryLevel.' + str(i) + '%' for i in range(101)\n"))

User avatar
kgschlosser
Site Admin
Posts: 5504
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Event on external monitor on/off

Post by kgschlosser » Sat Aug 22, 2020 4:58 pm

you need to upgrade the version of EventGhost you are running to 0.5 It can be downloaded here.
https://github.com/EventGhost/EventGhos ... v0.5.0-rc6
then the new version of the system plugin should work.
If you like the work I have been doing then feel free to Image

Dzikerino
Posts: 6
Joined: Sat Aug 22, 2020 3:08 am

Re: Event on external monitor on/off

Post by Dzikerino » Sun Aug 23, 2020 10:15 am

It fixed the installation issue, but can't see any events on monitor on/off - just on plug/unplug. Do you have any ideas why?

User avatar
kgschlosser
Site Admin
Posts: 5504
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Event on external monitor on/off

Post by kgschlosser » Tue Aug 25, 2020 8:58 am

as a matter of fact I do know why. It is because your TV is transmitting EDID data in a standby state (most do not do this). Do not fret tho, This is a solvable problem!!!

I am going to have to key up a script for you to use that will leverage the Windows API and DDC/CI (Display Data Channel/Command Interface) so we can talk directly to the TV and see if we can get the TV's power state.

But before I do that do you mind telling me the manufacturer and model of the TV? We may already have a plugin for it that will provide us with the power status of it.
If you like the work I have been doing then feel free to Image

Dzikerino
Posts: 6
Joined: Sat Aug 22, 2020 3:08 am

Re: Event on external monitor on/off

Post by Dzikerino » Fri Aug 28, 2020 8:52 am

Sure thing, it's LG 42LG5000-ZA.

User avatar
kgschlosser
Site Admin
Posts: 5504
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Event on external monitor on/off

Post by kgschlosser » Fri Aug 28, 2020 8:13 pm

OK so with that TV using some kind of a network API is not going to work. The TV does however have RS232C I do not know if you computer has RS232 or not. a lot of them do in the form of a header on the mainboard and what needs to be gotta in a header to DB9 adapter. I can try the CCD/CI method to see if we can get a response from the TV and if that doesn't work then using the RS232 is going to be your only available solution.
If you like the work I have been doing then feel free to Image

dan Edens
Experienced User
Posts: 110
Joined: Mon Sep 24, 2018 7:57 pm

Re: Event on external monitor on/off

Post by dan Edens » Tue Sep 01, 2020 1:57 am

snap I knew I was saving that stack of rs232s for something. lol

Dzikerino
Posts: 6
Joined: Sat Aug 22, 2020 3:08 am

Re: Event on external monitor on/off

Post by Dzikerino » Tue Sep 15, 2020 6:49 pm

I don't think I'll be able to work with RS232 since it's a laptop. What about this CCD/CI method?

User avatar
kgschlosser
Site Admin
Posts: 5504
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Event on external monitor on/off

Post by kgschlosser » Tue Sep 15, 2020 9:14 pm

OK if it is a laptop it is not going to work. You need an RS232 adapter not a Serial TTL adapter. a lot of USB to serial adapter manufacturers tell you it's RS232 when in fact it really is not. USB only has a 5volt output so there for the data lines in the serial will only have a max range of +5 to -5. where as RS3232 is +12 to -12 and unfortunately the RS232 specification does not allow for the voltage to be as low as 5 volts. You would also have to make a voltage divider in order to lower the 12v coming out of the TV to 5v so you don't cook the usb to serial adapter.

They do make USB to RS232 adapters, they are harder to locate and they will also have to be plugged into a wall outlet,. This is how you can tell if it is rs232 or not usually. You can try the one that you have. I personally have never had any luck getting one of those things to work with a device that is explicitly RS232. I did some poking about and I was not able to locate a USB to 12v RS232 adapter. They used to make them but maybe not anymore. I am sure someone does and it is probably going to be expensive if they do.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 5504
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Event on external monitor on/off

Post by kgschlosser » Tue Sep 15, 2020 9:16 pm

who is the manufacturer of the video card in the laptop??
If you like the work I have been doing then feel free to Image

Dzikerino
Posts: 6
Joined: Sat Aug 22, 2020 3:08 am

Re: Event on external monitor on/off

Post by Dzikerino » Fri Sep 25, 2020 9:21 am

it's NVIDIA GeForce GTX 1070.

Full laptop's spec:
https://www.asus.com/pl/Laptops/ROG-G75 ... fications/

Post Reply