找回密码
 加入
搜索
查看: 9989|回复: 25

可有关闭显示器的AU3代码?谢谢

 火... [复制链接]
发表于 2010-1-28 01:19:28 | 显示全部楼层 |阅读模式
本帖最后由 llztt 于 2010-1-28 13:21 编辑

如题啦,再次感谢

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-1-28 02:28:59 | 显示全部楼层
貌似没见过,我是用 nircmd 搞定的
发表于 2010-1-28 03:01:24 | 显示全部楼层
发表于 2010-1-28 04:23:33 | 显示全部楼层
回复 3# ceoguang


    忘了…… 恶搞,没测试…… :)
发表于 2010-1-28 08:44:44 | 显示全部楼层
楼上的,你不是吧
ceoguang 发表于 2010-1-28 03:01



    我也想起这张贴来了。
 楼主| 发表于 2010-1-28 09:27:31 | 显示全部楼层
看那代码应该
DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_Off)
Sleep(5000)
DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_On)
为关闭显示器的代码,但测试结果是没反应

afan的nircmd monitor off,也测试了,显示器(LCD的)关闭1秒又自己亮了,而千宇自动关机里的那个关闭显示功能就工作正常,呵呵,很郁闷
发表于 2010-1-28 11:15:19 | 显示全部楼层
好像不怎么行!
 楼主| 发表于 2010-1-28 11:23:25 | 显示全部楼层
又找了个命令行工具,测试正常,可就是不太想用外置工具,AU3自身难道就不能解决?呵呵
发表于 2010-1-28 11:25:29 | 显示全部楼层
我也是
但是nircmd 好用

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2010-1-28 11:41:05 | 显示全部楼层
Nircmd不行,我的测试结果。。。屏幕黑了下,但立刻又亮了。。17LCD正屏
发表于 2010-1-28 12:36:41 | 显示全部楼层
在 XP和 Win7下测试都通过了
Opt("WinTitleMatchMode", 4)

$hwnd = WinGetHandle("classname=Progman")
$user32 = DllOpen("user32.dll")
Global Const $lciWM_SYSCommand = 274
Global Const $lciSC_MonitorPower = 61808
Global Const $lciPower_Off = 2
Global Const $lciPower_On = -1

DllCall($user32, "int", "SendMessage", "hwnd", $hwnd, "int", $lciWM_SYSCommand, "int", $lciSC_MonitorPower, "int", $lciPower_Off)

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

发表于 2010-1-28 12:46:35 | 显示全部楼层
#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, "监视器 开/关", "按 F11 关闭监视器" & @LF & _
                            "按 F10 返回打开监视器" & @LF & _
                            "按 ESC 退出程序.")
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', $lciWM_SYSCommand, _
                                                'int', $lciSC_MonitorPower, _
                                                'int', $lciPower_On)
EndFunc
Func _Monitor_OFF()
    $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
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

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

发表于 2010-1-28 13:05:16 | 显示全部楼层
呵呵,不错,学习一下。。
 楼主| 发表于 2010-1-28 13:21:31 | 显示全部楼层
11# 12#代码测试通过,非常感谢
发表于 2010-1-28 13:36:03 | 显示全部楼层
晕,问题出在了 Opt("WinTitleMatchMode", 4) 上
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-16 17:33 , Processed in 0.083180 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表