[AAuto] 纯文本查看 复制代码
#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\..\..\..\My Documents\Desktop\显示器_00001.ico
#AutoIt3Wrapper_Outfile=..\..\..\..\My Documents\Desktop\关闭显示器.Exe
#AutoIt3Wrapper_Outfile_x64=关闭显示器64.Exe
#AutoIt3Wrapper_Res_Comment=关闭显示器小软件,千万记住快捷键
#AutoIt3Wrapper_Res_Fileversion=1.0.0.3
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_ProductName=关闭显示器
#AutoIt3Wrapper_Res_ProductVersion=1.0
#AutoIt3Wrapper_Res_Language=2052
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Global Const $lciWM_SYSCommand = 274
Global Const $lciSC_MonitorPower = 61808
Global Const $lciPower_Off = 2
Global Const $lciPower_On = -1
Global $MonitorIsOff = False
HotKeySet("^!{F10}", "_Monitor_OFF")
HotKeySet("^!{F11}", "_Monitor_ON")
HotKeySet("^!{Esc}", "_Quit")
MsgBox(32, "程序提示,一定要记住快捷键~!", "按 CTRL+ALT+F10 关闭监视器" & @LF & _
"按 CTRL+ALT+F11 打开监视器" & @LF & _
"按 CTRL+ALT+ESC 退出本程序" & @LF & _
"请记住快捷键 本窗口20秒后关闭", 20)
While 1
Sleep(10)
WEnd
Func _Monitor_ON()
MsgBox(64, "提示", "已打开显示器", 2)
$MonitorIsOff = False
Local $Progman_hwnd = WinGetHandle('[CLASS:Progman]')
DllCall('user32.dll', 'int', 'SendMessage', _
'hwnd', $Progman_hwnd, _
'int', $lciWM_SYSCommand, _
'int', $lciSC_MonitorPower, _
'int', $lciPower_On)
EndFunc ;==>_Monitor_ON
Func _Monitor_OFF()
MsgBox(48, "警告", "已关闭显示器", 2)
$MonitorIsOff = True
Local $Progman_hwnd = WinGetHandle('[CLASS:Progman]')
While $MonitorIsOff = True
DllCall('user32.dll', 'int', 'SendMessage', _
'hwnd', $Progman_hwnd, _
'int', $lciWM_SYSCommand, _
'int', $lciSC_MonitorPower, _
'int', $lciPower_Off)
_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 _Quit()
_Monitor_ON()
MsgBox(64, "提示", "5秒后退出本程序", 5)
Exit
EndFunc ;==>_Quit