turn-off-screen icon indicating copy to clipboard operation
turn-off-screen copied to clipboard

Script Hangs in Windows 8.1

Open Wikilicious opened this issue 11 years ago • 2 comments

Thanks for the script. I encountered an issue using it in Windows 8.1. It works fine, however; the script hangs even after I wake my monitors again. e.g.
SC_MONITORPOWER = 0xF170 win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND, SC_MONITORPOWER, 2) print 'All done'

The Python window stays open even after I wake my monitors i.e. it never reaches the print 'All done' statement.

Wikilicious avatar Jan 06 '15 19:01 Wikilicious

I tested this on Windows 7 and had no issues so I assume it's a Windows 8.1 issue. I have devised a remedy for my issue

import win32gui import win32con from os import getpid, system from threading import Timer

def force_exit(): pid = getpid() system('taskkill /pid %s /f' % pid)

t = Timer(1, force_exit) t.start() SC_MONITORPOWER = 0xF170 win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND, SC_MONITORPOWER, 2)

The script waits 1 second then forcefully kills itself. The extra imports are part of Python's standard library.

Wikilicious avatar Jan 06 '15 20:01 Wikilicious

Hi @Wikilicious, thank you for reporting the issue. Could you please do a pull request. Not that i don't have the time, I would like you to be the commit's author.

arjun024 avatar Jan 07 '15 07:01 arjun024