I downloaded the source from the Backlight page and it looks like he works with SetMonitorBrightness / GetMonitorBrightness too.
So normaly it should work for you.
Tested with:
- Windows 7 Enterprise - x64
- Windows 7 Ultimate - x64
- Windows 8.1 Enterprise N - x64
- 22" Widescreen Display by Asus
- 24" Widescreen Display
Did you include the lib in your script?
Minimum supported client: Windows Vista
Minimum supported server: Windows Server 2008
[Class] Monitor (Brightness, Contrast, Gamma Ramp)
Re: Class Monitor (Brightness, Contrast & Gamma)
[AHK] v2.0.18 | [WIN] 11 Pro (23H2) | [GitHub] Profile
Re: Class Monitor (Brightness, Contrast & Gamma)
Hmm, that's odd. I'm using Win 8.1 Pro and a Dell 2711 which seems to support backlight control via software seeing as the Rainmeter widget worked, but if yours uses the same functions I'm not sure what could be causing the problem.jNizM wrote:I downloaded the source from the Backlight page and it looks like he works with SetMonitorBrightness / GetMonitorBrightness too.
So normaly it should work for you.
For reference when I launch your regular Class Monitor GUI script it only detects the Gamma setting, the Brightness and Contrast inputs are blank. When I enter a value and click 'Set' the monitor flashes briefly but no change in brightness.
The Class_Monitor.ahk? If so yes, had it in the same directory. Unless you mean something else.jNizM wrote:Did you include the lib in your script?
Re: Class Monitor (Brightness, Contrast & Gamma)
Great work, here goes my two cents
Your small GUI program calls Monitor.SetDeviceGammaRamp() to change the gamma, but that method does not change the gamma, but the brightness. To change the gamma you have to set the gamma ramp using a "gamma function" instead of a linear function and then change the value of gamma. Here a small piece of code i wrote that changes gamma and brightness: try it out with gamma going from 0.1 to 2.2 (it's actually the inverse of gamma), you will see how it's different from brightness
Your small GUI program calls Monitor.SetDeviceGammaRamp() to change the gamma, but that method does not change the gamma, but the brightness. To change the gamma you have to set the gamma ramp using a "gamma function" instead of a linear function and then change the value of gamma. Here a small piece of code i wrote that changes gamma and brightness: try it out with gamma going from 0.1 to 2.2 (it's actually the inverse of gamma), you will see how it's different from brightness
Code: Select all
SetDeviceGammaRamp(brightness, gamma=1.0)
{
(brightness > 256) ? brightness := 256
(brightness < 0) ? brightness := 0
VarSetCapacity(gr, 512*3)
x := 1/gamma
Loop, 256
{
(nValue:=(brightness+128)*(A_Index-1))>65535 ? nValue:=65535
nValue := (nValue**x/65535**x)*65535 ; here's where we change the gamma
NumPut(nValue, gr, 2*(A_Index-1), "Ushort")
NumPut(nValue, gr, 512+2*(A_Index-1), "Ushort")
NumPut(nValue, gr, 1024+2*(A_Index-1), "Ushort")
}
hDC := DllCall("GetDC", "Uint", hwin)
DllCall("SetDeviceGammaRamp", "Uint", hDC, "Uint", &gr)
DllCall("ReleaseDC", "Uint", 0, "Uint", hDC)
}
Re: Class Monitor (Brightness, Contrast & Gamma)
Hi, Now it may be similar to f. lux as change the color temperature of it?
Re: Class Monitor (Brightness, Contrast & Gamma)
I work on it atm..
- MonitorBrightness
- MonitorContrast
- MonitorColorTemperature
- MonitorRedGreenOrBlueDrive
- MonitorRedGreenOrBlueGain
- MonitorBrightness
- MonitorContrast
- MonitorColorTemperature
- MonitorRedGreenOrBlueDrive
- MonitorRedGreenOrBlueGain
[AHK] v2.0.18 | [WIN] 11 Pro (23H2) | [GitHub] Profile
Re: Class Monitor (Brightness, Contrast & Gamma)
Thank you for those functions!
I have included them to AutoHotFlow. There are now two new actions: Set monitor settings and Get monitor settings. With this you can change the brightness, contrast, gamma, color gain and color temperature.
I've extended the class a little bit. There are two new functions for getting and setting the color gain for each color. You can download it here.
Why did you comment out the functions for setting and getting the color temperature? It works on one of my monitors, although not for every temperature.
I have included them to AutoHotFlow. There are now two new actions: Set monitor settings and Get monitor settings. With this you can change the brightness, contrast, gamma, color gain and color temperature.
I've extended the class a little bit. There are two new functions for getting and setting the color gain for each color. You can download it here.
Why did you comment out the functions for setting and getting the color temperature? It works on one of my monitors, although not for every temperature.
Scripting is too complicated? Try AutoHotFlow, the graphical automation tool! Written in AutoHotkey.
Re: Class Monitor (Brightness, Contrast & Gamma)
Hi bichlepa,
I need to fix a mistake in my class. The new version will be available in 1 or 2 days (incl. new GUI).
Latest Beta:
- Class_Monitor.ahk (Beta)
- Class_Monitor_GUI_Classic.ahk (Beta)
I need to fix a mistake in my class. The new version will be available in 1 or 2 days (incl. new GUI).
Latest Beta:
- Class_Monitor.ahk (Beta)
- Class_Monitor_GUI_Classic.ahk (Beta)
[AHK] v2.0.18 | [WIN] 11 Pro (23H2) | [GitHub] Profile
Re: Class Monitor (Brightness, Contrast & Gamma)
I wonder if this is the reason changing the brightness wasn't working for me.Peixoto wrote:Great work, here goes my two cents
Your small GUI program calls Monitor.SetDeviceGammaRamp() to change the gamma, but that method does not change the gamma, but the brightness.
Getting this error when launching Class_Monitor_GUI_Classic.ahk (and also the script you provided to me earlier): http://i.imgur.com/hJftEhj.pngjNizM wrote:Hi bichlepa,
I need to fix a mistake in my class. The new version will be available in 1 or 2 days (incl. new GUI).
Latest Beta:
- Class_Monitor.ahk (Beta)
- Class_Monitor_GUI_Classic.ahk (Beta)
Re: Class Monitor (Brightness, Contrast & Gamma)
@Bleep
Install the latest AutoHotkey Version
Ref:
- ObjRawSet
- Changelog (1.1.21.00 - March 28, 2015)
- Changelog (1.1.22.04 - August 19, 2015)
Install the latest AutoHotkey Version
Ref:
- ObjRawSet
- Changelog (1.1.21.00 - March 28, 2015)
- Changelog (1.1.22.04 - August 19, 2015)
[AHK] v2.0.18 | [WIN] 11 Pro (23H2) | [GitHub] Profile
Re: Class Monitor (Brightness, Contrast & Gamma)
Code: Select all
; GLOBAL SETTINGS ===============================================================================================================
#Warn
#NoEnv
#SingleInstance Force
SetBatchLines -1
global Reset := 128
global LoadRed := Brightness.Get().Red
global LoadGreen := Brightness.Get().Green
global LoadBlue := Brightness.Get().Blue
global LoadAll := ((LoadRed = LoadGreen) && (LoadRed = LoadBlue) && (LoadGreen = LoadBlue)) ? LoadRed : " - "
; GUI ===========================================================================================================================
Gui, Margin, 5, 5
Gui, Font, s16 w800 q4 c76B900, MS Shell Dlg 2
Gui, Add, Text, xm ym w240 0x0201, % "Display Brightness"
Gui, Font, s9 w400 q1 c000000, MS Shell Dlg 2
Gui, Add, GroupBox, xm y+15 w240 h110, % "Change Brightness (RGB)"
Gui, Font, s9 w400 q1 c000000, MS Shell Dlg 2
Gui, Add, Text, xp+10 yp+25 w70 h22 0x0200, % "Red"
Gui, Add, Edit, x+1 yp w80 h22 0x2002 Limit3 hwndhEdit1 vBRed
Gui, Add, UpDown, Range0-255, % LoadRed
Gui, Font, s9 w400 q1 csilver, MS Shell Dlg 2
Gui, Add, Text, x+5 yp w65 h22 0x0200, % "(0 - 255)"
Gui, Font, s9 w400 q1 c000000, MS Shell Dlg 2
Gui, Add, Text, xs+10 y+4 w70 h22 0x0200, % "Green"
Gui, Add, Edit, x+1 yp w80 h22 0x2002 Limit3 hwndhEdit2 vBGreen
Gui, Add, UpDown, Range0-255, % LoadGreen
Gui, Font, s9 w400 q1 csilver, MS Shell Dlg 2
Gui, Add, Text, x+5 yp w65 h22 0x0200, % "(0 - 255)"
Gui, Font, s9 w400 q1 c000000, MS Shell Dlg 2
Gui, Add, Text, xs+10 y+4 w70 h22 0x0200, % "Blue"
Gui, Add, Edit, x+1 yp w80 h22 0x2002 Limit3 hwndhEdit3 vBBlue
Gui, Add, UpDown, Range0-255, % LoadBlue
Gui, Font, s9 w400 q1 csilver, MS Shell Dlg 2
Gui, Add, Text, x+5 yp w65 h22 0x0200, % "(0 - 255)"
Gui, Font, s9 w400 q1 c000000, MS Shell Dlg 2
Gui, Add, GroupBox, xm y+15 w240 h60, % "Change Brightness (ALL)"
Gui, Font, s9 w400 q1 c000000, MS Shell Dlg 2
Gui, Add, Text, xp+10 yp+25 w70 h22 0x0200, % "All"
Gui, Add, Edit, x+1 yp w80 h22 0x2002 Limit3 hwndhEdit4 vBAll
Gui, Add, UpDown, Range0-255, % LoadAll
Gui, Font, s9 w400 q1 csilver, MS Shell Dlg 2
Gui, Add, Text, x+5 yp w65 h22 0x0200, % "(0 - 255)"
Gui, Add, Button, xm+20 y+20 w70 gSetRGBSettings, % "Set RGB"
Gui, Add, Button, x+5 yp w70 gSetALLSettings, % "Set ALL"
Gui, Add, Button, x+5 yp w70 gResetSettings, % "Reset"
Gui, Show, AutoSize
return
; SCRIPT ========================================================================================================================
SetRGBSettings:
Gui, Submit, NoHide
Brightness.Set(BRed, BGreen, BBlue)
GuiControl,, BAll, % (BRed = BGreen) && (BRed = BBlue) && (BGreen = BBlue) ? BRed : " - "
return
SetALLSettings:
Gui, Submit, NoHide
if BAll is digit
{
Brightness.Set(BAll, BAll, BAll)
GuiControl,, BRed, % BAll
GuiControl,, BGreen, % BAll
GuiControl,, BBlue, % BAll
}
else
MsgBox % BAll " is no digit"
return
ResetSettings:
Brightness.Set(Reset, Reset, Reset)
GuiControl,, BRed, % Reset
GuiControl,, BGreen, % Reset
GuiControl,, BBlue, % Reset
GuiControl,, BAll, % Reset
return
; EXIT ==========================================================================================================================
GuiClose:
GuiEscape:
ExitApp
; FUNCTIONS =====================================================================================================================
Class Brightness
{
Get() ; http://msdn.com/library/dd316946(vs.85,en-us)
{
VarSetCapacity(buf, 1536, 0)
DllCall("gdi32.dll\GetDeviceGammaRamp", "Ptr", hDC := DllCall("user32.dll\GetDC", "Ptr", 0, "Ptr"), "Ptr", &buf)
CLR := {}
CLR.Red := NumGet(buf, 2, "UShort") - 128
CLR.Green := NumGet(buf, 512 + 2, "UShort") - 128
CLR.Blue := NumGet(buf, 1024 + 2, "UShort") - 128
return CLR, DllCall("user32.dll\ReleaseDC", "Ptr", 0, "Ptr", hDC)
}
Set(ByRef red := 128, ByRef green := 128, ByRef blue := 128) ; http://msdn.com/library/dd372194(vs.85,en-us)
{
loop % VarSetCapacity(buf, 1536, 0) / 6
{
NumPut((r := (red + 128) * (A_Index - 1)) > 65535 ? 65535 : r, buf, 2 * (A_Index - 1), "UShort")
NumPut((g := (green + 128) * (A_Index - 1)) > 65535 ? 65535 : g, buf, 512 + 2 * (A_Index - 1), "UShort")
NumPut((b := (blue + 128) * (A_Index - 1)) > 65535 ? 65535 : b, buf, 1024 + 2 * (A_Index - 1), "UShort")
}
ret := DllCall("gdi32.dll\SetDeviceGammaRamp", "Ptr", hDC := DllCall("user32.dll\GetDC", "Ptr", 0, "Ptr"), "Ptr", &buf)
return ret, DllCall("user32.dll\ReleaseDC", "Ptr", 0, "Ptr", hDC)
}
}
; ===============================================================================================================================
[AHK] v2.0.18 | [WIN] 11 Pro (23H2) | [GitHub] Profile
Re: Class Monitor (Brightness, Contrast & Gamma)
Thanks, this did the trick. Your GUI script now works for detecting and setting brightness and contrastjNizM wrote:@Bleep
Install the latest AutoHotkey Version
Tried the script you made for me on the last page and it actually adjusted the brightness this time, but only for one brightness step and after that the hotkeys failed to change the brightness :/ For what it's worth I changed the default hotkeys in the script to +^!- (Ctrl+Shift+Alt+-) for increasing brightness and +^!= (Ctrl+Shift+Alt+=) for decreasing the brightness as my keyboard lacks numpad keys.
Re: Class Monitor (Brightness, Contrast & Gamma)
Hi jNizM,
You can post a simple example to modify the color temperature?
I try to use SetMonitorColorTemperature() AND GetMonitorColorTemperature(), But to no avail.
I hope it can replace flux.
thanks.
You can post a simple example to modify the color temperature?
I try to use SetMonitorColorTemperature() AND GetMonitorColorTemperature(), But to no avail.
I hope it can replace flux.
thanks.
Re: Class Monitor (Brightness, Contrast & Gamma)
Update:
Rewritten
Rewritten
[AHK] v2.0.18 | [WIN] 11 Pro (23H2) | [GitHub] Profile
-
- Posts: 19
- Joined: 02 Aug 2017, 23:22
Re: Class Monitor (Brightness, ColorTemperature)
How to make two settings to work with different hot keys?
Re: Class Monitor (Brightness, ColorTemperature)
Update:
- Bug fixes (thx to jee)
- Added Hotkey example
- Bug fixes (thx to jee)
- Added Hotkey example
[AHK] v2.0.18 | [WIN] 11 Pro (23H2) | [GitHub] Profile
-
- Posts: 19
- Joined: 02 Aug 2017, 23:22
Re: Class Monitor (Brightness, ColorTemperature)
can i make hotkey f1 f2 or just f1 two different options? and its nice to make contrast and brightness separate like in nvidia control panel.jNizM wrote:Update:
- Bug fixes (thx to jee)
- Added Hotkey example
Re: Class Monitor (Brightness, ColorTemperature)
Example for F1 and F2
Code: Select all
; GLOBAL SETTINGS ===============================================================================================================
#NoEnv
#SingleInstance Force
#Persistent
SetBatchLines -1
; SCRIPT ========================================================================================================================
F1::Monitor.SetBrightness(100, 100, 90) ; Red - Green - Blue
F2::Monitor.SetBrightness(90, 90, 80) ; Red - Green - Blue
; INCLUDES ======================================================================================================================
#Include Class_Monitor.ahk
; ===============================================================================================================================
[AHK] v2.0.18 | [WIN] 11 Pro (23H2) | [GitHub] Profile
-
- Posts: 19
- Joined: 02 Aug 2017, 23:22
Re: Class Monitor (Brightness, ColorTemperature)
Is it hard to make contrast aand brightness separated??jNizM wrote:Example for F1 and F2Code: Select all
; GLOBAL SETTINGS =============================================================================================================== #NoEnv #SingleInstance Force #Persistent SetBatchLines -1 ; SCRIPT ======================================================================================================================== F1::Monitor.SetBrightness(100, 100, 90) ; Red - Green - Blue F2::Monitor.SetBrightness(90, 90, 80) ; Red - Green - Blue ; INCLUDES ====================================================================================================================== #Include Class_Monitor.ahk ; ===============================================================================================================================
Re: Class Monitor (Brightness, ColorTemperature)
I used this in a project recently. If it made any money I'd send you a big cut, the class works perfectly.
v1: biga.ahk | array.ahk | string-similarity | graphicsearch.ahk | midday.ahk | expect.ahk
Re: Class Monitor (Brightness, ColorTemperature)
Glad it works for you. Report any bugs or requests you got.
[AHK] v2.0.18 | [WIN] 11 Pro (23H2) | [GitHub] Profile
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: wilkster and 46 guests