C# 设置屏幕亮度 Windows 7

标签 c# windows-7 screen-brightness

我想自己调节屏幕亮度。因为 Windows 让我只能在有限的范围内进行调整。我想将显示屏从 0 调暗到 100%,然后将其关闭/打开。如果 Windows 可以自动执行它应该是可能的(昏暗显示:x 分钟后/关闭显示:x 分钟后)。我尝试了一些我在谷歌上找到的资源和类(class)。但它们都不起作用。

你有没有试过这个或者你能推荐我任何有效的代码吗?

感谢您的回复。

最佳答案

您可以使用 WmiSetBrightness方法:

using System.Management;
//...
static void SetBrightness(byte targetBrightness) {
    ManagementScope scope = new ManagementScope("root\\WMI");
    SelectQuery query = new SelectQuery("WmiMonitorBrightnessMethods");
    using(ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query)) {
        using(ManagementObjectCollection objectCollection = searcher.Get()) {
            foreach(ManagementObject mObj in objectCollection) {
                mObj.InvokeMethod("WmiSetBrightness",
                    new Object[] { UInt32.MaxValue, targetBrightness });
                break;
            }
        }
    }
}

更多详情请看Brightness Control in WDDMMonitor Configuration Functions

关于C# 设置屏幕亮度 Windows 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8194006/

相关文章:

visual-studio - Visual Studio 已停止工作 - 在 Win 7 上

c++ - QCombobox::setView 在 Windows 7 上崩溃应用程序

android - 如何像屏幕过滤器一样降低亮度

ios - UIScreen Brightness 属性

c# - 如果字符串值不为 null 或为空,则在字符串中添加 "| "

c# - 在 C# 中禁用屏幕保护程序和电源选项

c# - 选择多个日期的计数

c# - FieldInfo.GetValue 为私有(private)成员返回 null 而调试器指示字段不为 null?

c++ - Visual Studio 2010 : When creating new project vs2010 wants to open html file of wizard

macos - 有没有办法查询 MacBook LCD 的当前亮度级别?