UPDATE (18/12/2008): Fixed a small bug where displays with a maximum display level of less than 100 were not scaled properly for display in the gadget (see comments). Now v1.1.0.0.
UPDATE (18/11/2008): I have added a download for the console app and code that adjusts the display brightness, as used by the gadget.
What's this?
Another Windows Vista gadget, that's what. It allows you to change your laptop's screen brightness with a click of the mouse from the sidebar.
Once you install this gadget, just hover over it and it'll tell you the allowed brightness levels on your display. Click, and your monitor brightness will change. Simple.
The process of changing the monitor's brightness may take a few seconds, so the sun icon on the gadget will blink to tell you it's doing something
.
Sometimes the current brightness reported by the gadget may be different to the actual brightness because of changes by other actions/programs (e.g. disconnecting/connecting power, or using Windows Mobility Center to adjust). Just give it a minute or two and it'll update itself again. The gadget is still fully operable when it's out of sync.
Why?
I got sick of having to call up the Windows Mobility Center each time I wanted to change my screen's brightness on my tablet (the keyboard function keys don't work unless I load the Toshiba Flash Cards thingy, which is nice when it works, but is slow and takes up too much memory).
What are the technical tidbits?
This gadget combines a bit of everything - javascript for the gadget logic, VBScript to get the monitor brightness details, and C# (.NET) to set the monitor brightness.
Why javascript for the gadget logic? Because I like javascript better than VBScript when manipulating HTML elements (the real answer being I know more javascript).
So why not use JScript to get the monitor brightness details? Because in the case of using access Windows methods and commands (and using WMI), I know more VBScript in that area and there is more support out there for it, given VBScript is Windows' main automation language (soon to be replaced by PowerShell I think).
And finally, why another language to set the monitor brightness? Because neither VBScript or JScript can handle the 64-bit integers required by the WMI method (and there doesn't seem to be a workaround method available). So I wrote a small console app in C#, and the gadget's VBScript simply runs that and passes a parameter telling it what brightness level to set it to.
Show me the goods!
Just so you're sure - this gadget requires Windows Vista. It won't work on anything else.
The download link is below - to install, simple double-click on the downloaded .gadget file. One more thing - if the file you downloaded does not end with .gadget, and instead ends with .zip or anything else, you must rename the file to end with .gadget or the gadget will not install. Otherwise, when you double-click on the file, you'll either see rubbish, or a zip folder full of XML, HTML and graphic files.
As usual, drop me a note if you have any problems, or suggestions. And let me know if you want the source code/binary to the console app - the rest you can get by simply unzipping the .gadget file.
Download: Display Brightness Vista Gadget
But I want the stuff behind-the-scenes!
I've gotten a few requests on code that does the heavy lifting, particularly the C# console app, so here it is - Display Brightness Console App. This is not required for the gadget to work.
Both the code (C#) and the compiled exe are in the zip file. You will need the Microsoft .NET Framework 2.0 or greater for the app to work (Vista comes with 2.0 out of the box). It will only work in Windows Vista - as far as I know, there is no standard way to change display brightness programmatically in Windows XP.
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.