neuralgia.

lessons from the trenches.

Gamma Panel replacement.

Windows 10’s version 1909 patch broke Gamma Panel, which I was using to modify my gamma settings on-the-fly via the use of hotkeys. Fortunately, there is an AutoHotkey script that interfaces with Windows API directly to control monitor settings (brightness, contrast, gamma). What is missing is hotkey support, which is straightforward to add:

^1:: ; CTRL + 1, default
Monitor.SetBrightness(100, "0")
Monitor.SetBrightness(90, "1")
Monitor.SetContrast(50, "0")
Monitor.SetContrast(75, "1")
Monitor.SetGammaRamp(128, 128, 128, "1")
Monitor.SetGammaRamp(128, 128, 128, "2")
return

^2:: ; CTRL + 2, preset 1
Monitor.SetBrightness(defaultSettings["Brightness_0"], "0")
Monitor.SetBrightness(defaultSettings["Brightness_1"], "1")
Monitor.SetContrast(defaultSettings["Contrast_0"] * 1.2, "0")
Monitor.SetContrast(defaultSettings["Contrast_1"] * 1.2, "1")
Monitor.SetGammaRamp(200, 200, 200, "1")
Monitor.SetGammaRamp(200, 200, 200, "2")
return

^3:: ; CTRL + 3, preset 2
Monitor.SetBrightness(defaultSettings["Brightness_0"], "0")
Monitor.SetBrightness(defaultSettings["Brightness_1"], "1")
Monitor.SetContrast(defaultSettings["Contrast_0"] * 1.2, "0")
Monitor.SetContrast(defaultSettings["Contrast_1"] * 1.2, "1")
Monitor.SetGammaRamp(240, 240, 240, "0")
Monitor.SetGammaRamp(240, 240, 240, "1")
return

^4:: ; CTRL + 4, high contrast
Monitor.SetBrightness(defaultSettings["Brightness_0"], "0")
Monitor.SetBrightness(defaultSettings["Brightness_1"], "1")
Monitor.SetContrast(defaultSettings["Contrast_0"] * 1.5, "0")
Monitor.SetContrast(defaultSettings["Contrast_1"] * 1.5, "1")
Monitor.SetGammaRamp(200, 200, 200, "0")
Monitor.SetGammaRamp(200, 200, 200, "1")
return

Changing the presets and the hotkeys should be relatively straightforward.

When toggling between gamma presets, there is a noticeable delay between applying each line of the code (brightness -> contrast -> gamma), so it is possible to mess up monitor settings by switching between profiles too quickly. This delay is either caused by AutoHotkey’s interpreter, the Windows API calls, or both together.

Windows 11 (or some Windows 10 patch) also changed the way monitors are referenced via the DLLs; changing the brightness / contrast / gamma settings used to affect all monitors, but now they only affect one.

Creating a simple Windows-native app should not be too complicated considering one can figure out how to make use of the Windows DLLs by looking at the AutoHotkey script.

Leave a Reply

Your email address will not be published. Required fields are marked *