有没有人知道在保持主显示屏亮度的同时调节辅助显示器的程序化方法?我已经调查了一些现有的软件,但大多数只会调暗所有显示器(或只是主显示器)。我觉得这可能是一个Windows注册表修改也许。 (这将适用于Windows 7平台)即使有人可以指向我可以修改屏幕亮度级别的注册表项。我认为这是在操作系统中处理的,并不总是在显示器本身。
非常感谢任何和所有帮助!
答案 0 :(得分:1)
http://msdn.microsoft.com/en-us/library/ms775240.aspx
使用SetMonitorBrightness API。
答案 1 :(得分:0)
这里最好的软件解决方案可能是为每个显示器创建一个无边框的分层窗口,覆盖整个显示器,并将其背景颜色设置为50%不透明黑色。如何执行此操作取决于您使用的工具包:WPF? Win32的? Qt的?
答案 2 :(得分:0)
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