After further investigating the script I wrote, I saw it wasn't a good script.
Meaning, while the script was in the loop, the CPU usage climbed to 50%.
The logic of the script was to keep sending the command to shutdown the monitor till one of the keys (space, left mouse button, right mouse button) were pressed:
Code:
^esc:: ; ctrl+esc hotkey that turns off the monitor.
Sleep 1000 ; Give user a chance to release keys (in case their release would wake up the monitor again).
Loop
{
; Turn Monitor Off:
SendMessage, 0x112, 0xF170, 1,, Program Manager ; 0x112 is WM_SYSCOMMAND, 0xF170 is SC_MONITORPOWER.
; Note for the above: Use -1 in place of 2 to turn the monitor on.
; Use 1 in place of 2 to activate the monitor's low-power mode
If ((GetKeyState("Space","P")) Or (GetKeyState("LButton","P")) Or (GetKeyState("Rbutton","P")))
{
SendMessage, 0x112, 0xF170, -1,, Program Manager
break
}
}
return
If anyone knows a way to boost this script into a better one, I would appreciate it.
Thanks,