1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| #NoTrayIcon
Global Const $lciWM_SYSCommand = 274 Global Const $lciSC_MonitorPower = 61808 Global Const $lciPower_Off = 2 Global Const $lciPower_On = -1
Global $MonitorIsOff = False
HotKeySet("{F11}", "_Monitor_OFF") HotKeySet("{F10}", "_Monitor_ON") HotKeySet("{Esc}", "_Quit")
MsgBox(64, "Monitor On/Off", "Press F11 to turn off the monitor." & @LF & _ "Press F10 to turn on the monitor back." & @LF & _ "Press ESC to turn on the monitor and exit program.")
While 1 Sleep(10) WEnd
Func _Monitor_ON() $MonitorIsOff = False Local $Progman_hwnd = WinGetHandle( DllCall( EndFunc
Func _Monitor_OFF() $MonitorIsOff = True Local $Progman_hwnd = WinGetHandle( While $MonitorIsOff = True DllCall( _IdleWaitCommit(0) Sleep(20) WEnd EndFunc
Func _IdleWaitCommit($idlesec) Local $iSave, $LastInputInfo = DllStructCreate ("uint;dword") DllStructSetData ($LastInputInfo, 1, DllStructGetSize ($LastInputInfo)) DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo)) Do $iSave = DllStructGetData ($LastInputInfo, 2) Sleep(60) DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo)) Until (DllStructGetData ($LastInputInfo, 2)-$iSave) > $idlesec Or $MonitorIsOff = False Return DllStructGetData ($LastInputInfo, 2)-$iSave EndFunc
Func _Quit() _Monitor_ON() Exit EndFunc
|