调暗辅助监视器

发布于 2024-10-02 19:51:40 字数 195 浏览 0 评论 0原文

有谁知道一种在保持主显示屏完全明亮的同时使辅助显示器变暗的编程方法?我研究了一些现有的软件,但大多数只会调暗所有显示器(或仅主显示器)。我觉得这可能是 Windows 注册表修改。 (这适用于 Windows 7 平台)即使有人可以向我指出可以修改屏幕亮度级别的注册表项。我认为这是在操作系统中处理的,而不总是在显示器本身中处理的。

非常感谢任何和所有的帮助!

Does anyone know a programmatic way of dimming secondary monitors while keeping the primary display screen fully bright? I have investigated some existing software, but most will only dim all monitors (or only the primary one). I feel like this might be a windows registry modification perhaps. (This would be for the Windows 7 platform) Even if someone could point me towards registry entries that can be modified for screen brightness levels. I think this is handled in the OS and not always in the monitor itself.

Any and all help is greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

独自唱情﹋歌 2024-10-09 19:51:40

这里最好的纯软件解决方案可能是为每个显示器创建一个无边框、分层的窗口,覆盖整个显示器,并将其背景颜色设置为 50% 不透明黑色。如何执行此操作取决于您使用的工具包:WPF? Win32? Qt?

Probably the best software-only solution here would be to create a borderless, layered window for each display, that covers the entire display, and set its background color to, say 50% opaque black. How you do this will depend on which toolkit you're using: WPF? Win32? Qt?

青瓷清茶倾城歌 2024-10-09 19:51:40

本·斯特劳布和我有同样的想法。我在 Visual Studio 2010 中使用 VB.NET 创建了这个,这可以帮助您入门吗?使用的一些代码来自 Codeproject 网站

Imports System.Runtime.InteropServices


Public Class Form1

Public Enum GWL As Integer
    ExStyle = -20
End Enum

Public Enum WS_EX As Integer
    Transparent = &H20
    Layered = &H80000
End Enum

Public Enum LWA As Integer
    ColorKey = &H1
    Alpha = &H2
End Enum

<DllImport("user32.dll", EntryPoint:="GetWindowLong")> _
Public Shared Function GetWindowLong( _
    ByVal hWnd As IntPtr, _
    ByVal nIndex As GWL _
        ) As Integer
End Function

<DllImport("user32.dll", EntryPoint:="SetWindowLong")> _
Public Shared Function SetWindowLong( _
    ByVal hWnd As IntPtr, _
    ByVal nIndex As GWL, _
    ByVal dwNewLong As WS_EX _
        ) As Integer
End Function

<DllImport("user32.dll", _
  EntryPoint:="SetLayeredWindowAttributes")> _
Public Shared Function SetLayeredWindowAttributes( _
    ByVal hWnd As IntPtr, _
    ByVal crKey As Integer, _
    ByVal alpha As Byte, _
    ByVal dwFlags As LWA _
        ) As Boolean
End Function

Private _InitialStyle As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    _InitialStyle = GetWindowLong(Me.Handle, GWL.ExStyle)
    Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
    Me.BackColor = Color.Black
    Me.Opacity = 0.1 'Range is 0 (Fully see through) to 1 (Fully opaque)
    Me.TopMost = True
    DimScreenByIndex(1) 'use 0, 1, etc depending on which screen you want to dim

    SetWindowLong(Me.Handle, GWL.ExStyle, _InitialStyle Or WS_EX.Layered Or WS_EX.Transparent)
    'Not needed if setting the opacity: SetLayeredWindowAttributes(Me.Handle, 0, 255 * 0.7, LWA.Alpha)

End Sub

Private Sub DimScreenByIndex(ByVal intScn As Integer)
    For intPtr As Integer = Screen.AllScreens.GetLowerBound(0) To Screen.AllScreens.GetUpperBound(0)
        If intPtr = intScn Then
            Me.Top = Screen.AllScreens(intPtr).Bounds.Top
            Me.Left = Screen.AllScreens(intPtr).Bounds.Left
            Me.Height = Screen.AllScreens(intPtr).Bounds.Height()
            Me.Width = Screen.AllScreens(intPtr).Bounds.Width
        End If
    Next
End Sub
End Class

Ben Straub had the same idea as me. I created this in Visual Studio 2010 with VB.NET which may get you started? Some code used from Codeproject website

Imports System.Runtime.InteropServices


Public Class Form1

Public Enum GWL As Integer
    ExStyle = -20
End Enum

Public Enum WS_EX As Integer
    Transparent = &H20
    Layered = &H80000
End Enum

Public Enum LWA As Integer
    ColorKey = &H1
    Alpha = &H2
End Enum

<DllImport("user32.dll", EntryPoint:="GetWindowLong")> _
Public Shared Function GetWindowLong( _
    ByVal hWnd As IntPtr, _
    ByVal nIndex As GWL _
        ) As Integer
End Function

<DllImport("user32.dll", EntryPoint:="SetWindowLong")> _
Public Shared Function SetWindowLong( _
    ByVal hWnd As IntPtr, _
    ByVal nIndex As GWL, _
    ByVal dwNewLong As WS_EX _
        ) As Integer
End Function

<DllImport("user32.dll", _
  EntryPoint:="SetLayeredWindowAttributes")> _
Public Shared Function SetLayeredWindowAttributes( _
    ByVal hWnd As IntPtr, _
    ByVal crKey As Integer, _
    ByVal alpha As Byte, _
    ByVal dwFlags As LWA _
        ) As Boolean
End Function

Private _InitialStyle As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    _InitialStyle = GetWindowLong(Me.Handle, GWL.ExStyle)
    Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
    Me.BackColor = Color.Black
    Me.Opacity = 0.1 'Range is 0 (Fully see through) to 1 (Fully opaque)
    Me.TopMost = True
    DimScreenByIndex(1) 'use 0, 1, etc depending on which screen you want to dim

    SetWindowLong(Me.Handle, GWL.ExStyle, _InitialStyle Or WS_EX.Layered Or WS_EX.Transparent)
    'Not needed if setting the opacity: SetLayeredWindowAttributes(Me.Handle, 0, 255 * 0.7, LWA.Alpha)

End Sub

Private Sub DimScreenByIndex(ByVal intScn As Integer)
    For intPtr As Integer = Screen.AllScreens.GetLowerBound(0) To Screen.AllScreens.GetUpperBound(0)
        If intPtr = intScn Then
            Me.Top = Screen.AllScreens(intPtr).Bounds.Top
            Me.Left = Screen.AllScreens(intPtr).Bounds.Left
            Me.Height = Screen.AllScreens(intPtr).Bounds.Height()
            Me.Width = Screen.AllScreens(intPtr).Bounds.Width
        End If
    Next
End Sub
End Class
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文