找回密码
 加入
搜索
查看: 3182|回复: 4

请问可以用API控制屏幕亮度吗?

[复制链接]
发表于 2009-2-1 20:38:25 | 显示全部楼层 |阅读模式
请问可以用API控制屏幕亮度吗?
发表于 2009-2-1 22:31:59 | 显示全部楼层
$scHwnd = DllCall("user32.dll", "hwnd", "GetDesktopWindow")
$hDC = DllCall("user32.dll", "hwnd", "GetDC", "hwnd", $scHwnd[0])
$PriBright = DllStructCreate("ulong[256];ulong[256];ulong[256]")


$resGetBright = DllCall("Gdi32.dll", "int", "GetDeviceGammaRamp", "hwnd", $hDC[0], "ptr", DllStructGetPtr($PriBright))

$NewBright = DllStructCreate("ulong[256];ulong[256];ulong[256]")

For $a = 1 to 256
       For $d = 1 to 3
        DllStructSetData($NewBright, $d, DllStructGetData($PriBright, 1, $a) / 2, $a)
      Next
Next

$res = DllCall("Gdi32.dll", "int", "SetDeviceGammaRamp", "hwnd", $hDC[0], "ptr", DllStructGetPtr($NewBright))
$PriBright = 0
$NewBright = 0

If $res[0] then msgBox(64, '', 'Done')
新亮度是根据当前亮度的一半值来的,所以不要调太大,也不要调太小,会造成花屏。虽然测试重启就恢复正常。

[ 本帖最后由 pusofalse 于 2009-2-2 05:59 编辑 ]

评分

参与人数 1金钱 +3 收起 理由
ceoguang + 3 nice code

查看全部评分

发表于 2009-2-1 23:22:44 | 显示全部楼层
nice code ............
发表于 2009-2-2 03:01:02 | 显示全部楼层
学习一下。
 楼主| 发表于 2009-2-2 12:16:38 | 显示全部楼层
我还在想说 为什么会花屏
再请问 ~用GUICtrlCreateSlider 控制
修改重点 在于 / 2  *2 这里吗?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-23 07:21 , Processed in 0.072061 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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