Xichael Posted February 26, 2008 Share Posted February 26, 2008 I'm trying to use a script for powering off my monitor (which works fine on it's own) with a HotKeySet. When I press the assigned hotkey, the monitor does power off, but only for a second, after which it flashes back on. How can I prevent this? HotKeySet ("#z", "MonOff") Opt("WinTitleMatchMode", 4) While 1 Sleep(50) WEnd Func MonOff() Local $HWND = WinGetHandle("classname=Progman") Local $WM_SYSCommand = 274 Local $SC_MonitorPower = 61808 DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, "int", $SC_MonitorPower, "int", 2) EndFunc Link to comment Share on other sites More sharing options...
Achilles Posted February 26, 2008 Share Posted February 26, 2008 Why not just use this one? It works good for me. The one you posted above doesn't work for me either... My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
FreeFry Posted February 26, 2008 Share Posted February 26, 2008 I'm trying to use a script for powering off my monitor (which works fine on it's own) with a HotKeySet. When I press the assigned hotkey, the monitor does power off, but only for a second, after which it flashes back on. How can I prevent this? HotKeySet ("#z", "MonOff") Opt("WinTitleMatchMode", 4) While 1 Sleep(50) WEnd Func MonOff() Local $HWND = WinGetHandle("classname=Progman") Local $WM_SYSCommand = 274 Local $SC_MonitorPower = 61808 DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", $WM_SYSCommand, "int", $SC_MonitorPower, "int", 2) EndFuncI don't really see why you created a new thread for this, as the discussion could've continued on the other thread. I'm not sure why this script would not work for you though, as it does turn of the monitor(s) and keeps it shut up(if you hold the key down). To prevent it from turning the screen back on instantly, try with just adding a Sleep(500) in the beginning of the MonOff function, that should let you have enough time to release the keys before the messsage get's sent. Link to comment Share on other sites More sharing options...
Xichael Posted February 26, 2008 Author Share Posted February 26, 2008 (edited) Why not just use this one? It works good for me. The one you posted above doesn't work for me either...For me the above script does the same thing (same problem as well) with half the code, which helps me more clearly understand how it works... I am on a laptop however, and haven't yet tried it on a desktop.To prevent it from turning the screen back on instantly, try with just adding a Sleep(500) in the beginning of the MonOff function, that should let you have enough time to release the keys before the messsage get's sent.That solves it completely. I figured the key releasing after being pressed was waking the screen back up, I just couldn't figure out how to prevent it... Huge thanks.I don't really see why you created a new thread for this...My apologies if creating a new thread was excessive. I just figured, new problem, new thread. I'll be easier to reference than were it buried on the last page of an unrelated topic. It's just that whenever I have a problem, I first search the forum for a solution. Hopefully this will be equally useful to someone else someday.Thanks again guys. Edited February 26, 2008 by Xichael Link to comment Share on other sites More sharing options...
FreeFry Posted February 26, 2008 Share Posted February 26, 2008 Owkidokie Glad you got it to work. Don't give up on getting that evil laptop key to work though. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now