-4

I'm trying to turn displays on using python. Found this code very useful but the problem is that it is turning display on for a brief moment and after like 1 second all displays are still 'entering power-save mode'. How can I make this 'power on' feature permanently?

zerocool
  • 733
  • 1
  • 7
  • 19
  • The linked code appears to be turning the displays _off_, so what do you expect? – martineau Jul 19 '16 at 10:01
  • I would expect that changing last parameter in win32gui.SendMessage() from '2' to '-1' (as documentation says) will do the trick. But it doesn't and behaviour is like I described in the question above. – zerocool Jul 19 '16 at 10:06
  • See http://stackoverflow.com/questions/25011141/turn-off-on-monitor-cant-turn-on – martineau Jul 19 '16 at 10:14

1 Answers1

0

Thanks for the hint, martineau! Simple sending message like that will not work:

win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND, SC_MONITORPOWER, -1)

I also tried:

ctypes.windll.user32.SetCursorPos(100, 20)

and

pygame.mouse.set_pos((random.choice(range(600)), random.choice(range(600))))

to utilise mouse, but this is nothing when compare to:

win32api.mouse_event(win32con.MOUSEEVENTF_ABSOLUTE|win32con.MOUSEEVENTF_MOVE,100,20)

mouse_event did the trick as explained here

Community
  • 1
  • 1
zerocool
  • 733
  • 1
  • 7
  • 19