Reputation: 1676
I am trying to write a simple console application for Windows 10 that changes the screen brightness. Ultimately, I want to use this application with AutoHotKey, but this is secondary.
In researching this, almost everything I found referred to Android, which doesn't help. I did find this Q&A about changing the screen brightness with C, but unfortunately that is for Linux.
This archived thread contains a script that (while appearing quite hacky) makes a good impression - but it
is deprecated, and on many [Systems] it will not return the full brightness settings array. So, where you should have 8 levels, IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS will only return 6, or none at all. (by jkiel, 1)
So I would prefer to use the WmiMonitorBrightness
class (2 3) over IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS
. It also provides a lot finer granularity, but I lack the skills to implement it correctly.
So how can I change the screen brightness on Windows 10? Possibly using the mentioned WmiMonitorBrightness
class? I don't mind if it is a C application, an AutoHotKey script or something else, that I can control from console.
Upvotes: 0
Views: 1838
Reputation: 1676
Looking for a solution, I found this software from 2008 which works like a charm for me on Windows 10. The developer provided the C# source and compiled application here. "You will need the Microsoft .NET Framework 2.0 or greater for the app to work."
Plus it supports the full granularity of setting brightness on your screen.
To use the console app, the following parameters are allowed:
- DisplayBrightnessConsole.exe This will return the current brightness level.
- DisplayBrightnessConsole.exe -getlevels This will return all possible brightness levels accepted by the display, separated by a new line.
- DisplayBrightnessConsole.exe 20 (or some other brightness level number) This will set the brightness level of the display to the parameter given, in this case, 20.
The code currently only works on single-display systems. If your system has more than one display, it will only work on the first (generally primary) display. It should be fairly easy to modify it to support more.
Possibly helpful for people using python - but it doesn't help in my specific case:
How can I detect brightness changes using Python and WMI on Windows 10?
Upvotes: 1