Re-enable monitor doesn't work on windows 8

If you have a question or need help, this is the place to be.

Re-enable monitor doesn't work on windows 8

Postby napoleon » Mon Apr 01, 2013 7:38 am

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

Postby napoleon » Mon Apr 01, 2013 12:58 pm

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.
napoleon
 
Posts: 2
Joined: Mon Apr 01, 2013 6:59 am

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

Postby Flyingsubs » Sat Aug 17, 2013 12:32 am

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

Thanks,
Flyingusbs
Flyingsubs
Experienced User
 
Posts: 87
Joined: Sat Dec 29, 2012 11:26 pm

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

Postby Neytrino-OnLine » Tue Aug 20, 2013 7:19 pm

Same issue, just using: Emulate Keystrokes: {Shift}
Sin©erely yours, Neytrino.
User avatar
Neytrino-OnLine
 
Posts: 12
Joined: Tue Aug 20, 2013 7:14 pm
Location: Moscow, Russia

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

Postby Flyingsubs » Mon Sep 02, 2013 5:08 am

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

-Flyingsubs
Flyingsubs
Experienced User
 
Posts: 87
Joined: Sat Dec 29, 2012 11:26 pm

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

Postby AceoStar » Thu Jan 12, 2017 1:58 am

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.
AceoStar
 
Posts: 9
Joined: Thu Jan 12, 2017 1:28 am

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

Postby kgschlosser » Fri Jan 13, 2017 5:47 pm

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: 2087
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

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

Postby kgschlosser » Fri Jan 13, 2017 11:50 pm

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
User avatar
kgschlosser
Site Admin
 
Posts: 2087
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

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

Postby AceoStar » Sat Jan 14, 2017 12:44 am

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!
AceoStar
 
Posts: 9
Joined: Thu Jan 12, 2017 1:28 am

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

Postby kgschlosser » Sat Jan 14, 2017 3:13 am

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
User avatar
kgschlosser
Site Admin
 
Posts: 2087
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

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

Postby AceoStar » Sat Jan 14, 2017 5:47 am

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.
AceoStar
 
Posts: 9
Joined: Thu Jan 12, 2017 1:28 am


Return to General Support

Who is online

Users browsing this forum: Bing [Bot] and 4 guests