Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Re-enable monitor doesn't work on windows 8

If you have a question or need help, this is the place to be.
Post Reply
napoleon
Posts: 2
Joined: Mon Apr 01, 2013 6:59 am

Re-enable monitor doesn't work on windows 8

Post by napoleon »

Hi,

I upgraded my media PC to windows 8 and now re-enable monitor doesn't work. It turns monitor on about 1 seconds and then again off. In event log I don't see any action that triggers action that turns monitor off again and it also happens when I create macro turn monitor off->wait 4 seconds->re-enable monitor and execute it manually. With exactly same configuration and on exactly same PC it worked well on winXP. I tried same in my windows 8 laptop(fs lifebook S7220) so the problem is general and not related to specific pc/hardware. I also tried to move mouse with macro and this also doesn't work but monitor is turned on(and stays on) when I move physical mouse or press key on keyboard.
Any ideas/workarounds? Right now the only workaround is that I don't turn off monitor at all but this means that monitor will stay on when PC is recording...

Eventghost version is latest(0.4.1.r1610)
Windows is Windows 8 Pro and all updates are installed

Br.
T├Ánu.
napoleon
Posts: 2
Joined: Mon Apr 01, 2013 6:59 am

Re: Re-enable monitor doesn't work on windows 8

Post by napoleon »

So far I figured out that EG mouse movement actions use SetCursorPos and seems that this just moves mouse pointer but doesn't trigger mouse event.
So far, one workaround is:
open Plugins\System\__init__.py
Add line after other imports:
import win32api, win32con
change:

Code: Select all

class MonitorPowerOn(eg.ActionBase):
    name = "Re-enable monitor"
    description = \
        "Turns on a display, when it is in low power or power-off "\
        "mode. Will also stop a running screensaver."
    iconFile = "icons/Display"

    def __call__(self):
        SendMessage(GetForegroundWindow(), WM_SYSCOMMAND, SC_MONITORPOWER, -1)
to:

Code: Select all

class MonitorPowerOn(eg.ActionBase):
    name = "Re-enable monitor"
    description = \
        "Turns on a display, when it is in low power or power-off "\
        "mode. Will also stop a running screensaver."
    iconFile = "icons/Display"

    def __call__(self):
		win32api.mouse_event(win32con.MOUSEEVENTF_MOVE, 1, 0)
		win32api.mouse_event(win32con.MOUSEEVENTF_MOVE, -1, 0)

But I don't like this workaround because changes will be lost when I upgrade EG. I will try later, maybe I can just make copy of System plugin and create my own but for me it takes some time because right now I don't know aything about python nor writing EG plugins.
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

Re: Re-enable monitor doesn't work on windows 8

Post by Flyingsubs »

Any update to this? I am very interested and have the same issue as you.

Thanks,
Flyingusbs
User avatar
Neytrino-OnLine
Experienced User
Posts: 99
Joined: Tue Aug 20, 2013 7:14 pm
Location: Moscow, Russia

Re: Re-enable monitor doesn't work on windows 8

Post by Neytrino-OnLine »

Same issue, just using: Emulate Keystrokes: {Shift}
Sin┬®erely yours, Neytrino.
Flyingsubs
Experienced User
Posts: 127
Joined: Sat Dec 29, 2012 11:26 pm

Re: Re-enable monitor doesn't work on windows 8

Post by Flyingsubs »

I see, I just did what you said and its a good work around. Thanks!

-Flyingsubs
AceoStar
Posts: 9
Joined: Thu Jan 12, 2017 1:28 am

Re: Re-enable monitor doesn't work on windows 8

Post by AceoStar »

Hello! This is still an issue on win 10, but the suggested fix addresses the issue. If anyone is looking for features to add, this is a great one to assist home automation integration with EG.
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Re-enable monitor doesn't work on windows 8

Post by kgschlosser »

I am going to test this one my windows 10 computer and see if it in fact is a problem.. and if so i will issue a pull request on github and see if we can't get this added to the core code
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Re-enable monitor doesn't work on windows 8

Post by kgschlosser »

I want to check something with the monitor power.. but this has to be a physical computer not a VM and it has to be running windows 8/10

you just have to paste this code into a python script and run it. it should turn the monitor off, and then a couple of seconds later turn it back on...


let me know if it works

TY

Code: Select all

import win32con
import win32gui
from threading import Timer

SC_MONITORPOWER = 0xF170
MONITOR_STATES = dict(
    OFF=2,
    STANDBY=1,
    ON=-1
)

def MonitorState(state):
    win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_STATES[state])
    
MonitorState('OFF')

Timer(3, MonitorState, args=('ON',)).start()
If you like the work I have been doing then feel free to Image
AceoStar
Posts: 9
Joined: Thu Jan 12, 2017 1:28 am

Re: Re-enable monitor doesn't work on windows 8

Post by AceoStar »

kgschlosser wrote:I want to check something with the monitor power.. but this has to be a physical computer not a VM and it has to be running windows 8/10

you just have to paste this code into a python script and run it. it should turn the monitor off, and then a couple of seconds later turn it back on...


let me know if it works

TY

Code: Select all

import win32con
import win32gui
from threading import Timer

SC_MONITORPOWER = 0xF170
MONITOR_STATES = dict(
    OFF=2,
    STANDBY=1,
    ON=-1
)

def MonitorState(state):
    win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_STATES[state])
    
MonitorState('OFF')

Timer(3, MonitorState, args=('ON',)).start()
kgschlosser. Sorry for not testing this sooner (going to your other thread next). Yes, this turned the monitor off and back on a few seconds later. I am on a physical windows 10 machine. Thanks for checking into it!
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Re-enable monitor doesn't work on windows 8

Post by kgschlosser »

OK it is the SendCommand function that EG uses that is not compatible.. not the actual act of turning the monitor on or off..

it's the -1 that the command probably has an issue with.


Not a biggie, i just wanted to make sure that i got the best possible solution put into the code. so i just wanted to verify what the actual issue was before going about it.. but I now know that this code is the solution and the route I will take. because it does not involve moving the mouse. this is a direct command and only affects the video output.
If you like the work I have been doing then feel free to Image
AceoStar
Posts: 9
Joined: Thu Jan 12, 2017 1:28 am

Re: Re-enable monitor doesn't work on windows 8

Post by AceoStar »

kgschlosser wrote:OK it is the SendCommand function that EG uses that is not compatible.. not the actual act of turning the monitor on or off..

it's the -1 that the command probably has an issue with.


Not a biggie, i just wanted to make sure that i got the best possible solution put into the code. so i just wanted to verify what the actual issue was before going about it.. but I now know that this code is the solution and the route I will take. because it does not involve moving the mouse. this is a direct command and only affects the video output.
Excellent! Happy to help. Thanks for all the great work.
Post Reply