#NoTrayIcon Global $MonitorIsOff = False HotKeySet("+!^{PAUSE}", "_Monitor_Switch") ;HotKeySet("+!^{PRINTSCREEN}", "_Monitor_ON") HotKeySet("+!^{Esc}", "_Quit") MsgBox(64, "Monitor On/Off", "Press Ctrl+Alt+Shift+Pause to turn off the monitor." & @LF & _ "Press Ctrl+Alt+Shift+PrnScrn to turn on the monitor back." & @LF & _ "Press Ctrl+Alt+Shift+Esc to turn on the monitor and exit program.") While 1 Sleep(10) WEnd Func _Monitor_ON() $MonitorIsOff = False Local $Progman_hwnd = WinGetHandle('[CLASS:Progman]') DllCall('user32.dll', 'int', 'SendMessage', 'hwnd', $Progman_hwnd, 'int', 274, 'int', 61808, 'int', -1) EndFunc ;==>_Monitor_ON Func _Monitor_OFF() $MonitorIsOff = True Local $Progman_hwnd = WinGetHandle('[CLASS:Progman]') While $MonitorIsOff = True DllCall('user32.dll', 'int', 'SendMessage', 'hwnd', $Progman_hwnd, 'int', 274, 'int', 61808, 'int', 2) _IdleWaitCommit(0) Sleep(20) WEnd EndFunc ;==>_Monitor_OFF 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 ;==>_IdleWaitCommit Func _Monitor_Switch() If $MonitorIsOff Then _Monitor_ON() Else _Monitor_OFF() EndIf EndFunc ;==>_Monitor_Switch Func _Quit() _Monitor_ON() Exit EndFunc ;==>_Quit |