Patrick Bader's Blog a blog about software development


Adjusting screen brightness with shortcuts

A while ago I installed Windows 7 on my Sony laptop. The good thing about it is it runs quite stable and most things just work. The bad thing some of the shortcuts with the blue "Fn" key don't work anymore. Adjusting the volume works perfectly fine, but setting the brightness of the LCD backlight does not.
Since Sony is not going to release any Windows 7 64 bit drivers for my model, I finally decided to write a little programm myself. This took several hours of searching for the right API to use. There are actualy three different ones:

  1. The first API I tried is called the Monitor Configuration of the Win32 API but did not work for my laptop (some kind of I2C transmission error occured)
  2. The Backlight Control Interface using IOCTL was the first approach that worked for me, but getting the current brightness is not supported on newer Windows versions
  3. So I ended up using WMI which is available for .NET and works surprisingly quite well.

Further usage information and a downloadable binary can be found on my Projects page
If you encounter bugs or have any suggestions please do not hesitate and give some feedback.

Comments (24) Trackbacks (0)
  1. hi. i’m iranian and have a Sony Z vaio Notebook.for 3 days I Search in Web And Find No Solution for problem with Fn keys. Today got your program and now i’m very happy. tnx very.
    sorry for bad english.
    Ya Ali.

  2. I’ve shared you article on digg, well written

  3. Hey! Was looking for a backlight-adjusting application for my Asus Eee PC. The backlight-adjusting hotkeys weren’t communicating with the Windows backlight controls with the Asus-supplied program, so this worked great as a replacement. Thanks a billion!

  4. Hi Patrick,

    I’m using your tool for quite a while now on my Vaio Z590 I bought back in 2008. Today I was trying to get it to run via the TaskScheduler of Win7, so that I don’t have to type my password every time into the elevation prompt when launching your tool. Unfortunately, the keyboard shortcuts are not captured when the program runs in the TaskScheduler. Do you have a suggestion, how I could make it run in the background everytime I logon, without UAC prompt?


  5. Hi Rainer,

    I’m suprised my tool requires elevation on your laptop. What you can try to do is running the tool as a startup script. To do this, open the Group Policy Editor (search for “group”in the start menu). Navigate to Computer Configuration –> Scripts –> Startup. Click “Add…” and browse to the script.
    Reboot your laptop afterwards. Don’t forget to remove the tool from the task planer. Hope this solves your problem.


  6. Hey Patrick,
    ich möchte gerne die Hintergrundbeleuchtung meines Notebooks per Skript steuern können. Gibt es eine Möglichkeit, dein Screen Brightness Tool v2 dafür zu verwenden, indem man es mit Parametern ansteuert? Z.B. tool.exe -100 für volle Helligkeit usw.?

  7. Hallo Sam,
    mit der neuen Version 2.1 des Tools, die heute erschienen ist, ist das möglich. Sie findet sich inklusive einer kurzen Beschreibung im “Projects” Bereich des Blogs. Alternativ kannst du sie auch direkt hier herunterladen.

  8. Fn-F6 to increase brightness
    F-F5 to decrease

  9. @Charles: The “Fn-*” hotkeys only work with a driver provided by Sony. Since Sony has not released a driver for the 64 bit version of Windows 7, these hotkeys aren’t working on 64 bit systems.

  10. Sounds like exactly the tool I need. Does it use DDC/CI? I guess not because it does not do anything on my Windows 7 64bit desktop / workstation. I guess this is made only for laptops?

  11. Yeah !!
    Just bought a Sony vaio vpceh and install a fresh new windows 7 Pro. Since yesterday i was knocking my head on wall trying to make the Fn keys to work.
    Droped it when i find you amazing tool 😀
    thanks a lot for sharing !

  12. Nope, it does not use DDC/CI, at least not directly. It’s based on the Windows WMI interface.

  13. Fantastic work! This is almost exactly what I’ve been trying to do, in (part 1) and (part 2) — in the process I’ve learned a ton about the windows api & kernel. Any chance you could share/open source your code? I(/we?) could do some cool things with it!

    Contact me when you get the chance!

    (also: is the image of the sun rendered with hardware acceleration?)

  14. ^ or whatever. It’s monday, my brain isn’t working, and you can ignore/disapprove these last two comments

  15. Hi Alexander,

    thank you. Since quite some time passed since the post and I haven’t been working on this recently, I first have to look for the code myself, hopefully I find it somewhere on my disk. If so, I’ll either uploaded it here or post the relevant lines of code. I haven’t released the code yet because it’s quite a mess.

    The sun is not rendered with hardware acceleration, it’s just an image and the boxes below are drawn using the Graphics member of the PaintEventArgs object in the onPaint method.

  16. I finally managed to retrieve the source code so here is the code of the Monitor class which contains methods for getting and setting the Brightness.
    For the code to work, you have to add the following References to your project:

  17. In the unlikely event that you read this, is it possible to modify the program to use different hotkeys (like shift + left/right arrow)?
    Thank you for writing this program by the way.

  18. Hi,
    making the program configurable would not be a hard task, the real problem at the moment is: The source code is on an old hard drive which is located at my parents’ place, so I can’t modify the code at the moment. So changing this will take some time, sorry.

  19. That’s okay, thanks for the reply :)

  20. Hi,
    i want shortcut for brightness for pc desktop. plz tell me if you know

  21. Hi,
    I think most monitors for desktop PCs do not support changing the brightness so you will have to use the on screen menu of the monitor to change its brightness. So I’m afraid there will be not tool for you :(

  22. Quick note, I ended up using autohotkey to psuedo-change the default hotkeys.

    For anyone else interested, the ahk script below

    >^Left::SendInput #{F5}
    >^Right::SendInput #{F6}

    Here Right Ctrl + L/R Arrow keys simulate pressing the default hotkeys, and of course screenbrightness.exe has to be running in the background. Placing the script & the exe in your startup folder takes care of everything. Hope this helps.

  23. Thanks a lot. Works perfect on my Elitebook 2540p. My function key for brightness no longer work but Screen Brightness v2.1 fixed it. I have been looking for a solution but only this one worked for me. Many many thanks.


Leave a comment

No trackbacks yet.