/Caps-Lock-LED

Creates a notification tray icon showing the status of the caps lock key.

Primary LanguageC#

What I Learned

  • How to work with the Windows Forms Application project template.
  • How to work with the telemetry systems in Windows (the IsKeyLocked method in particular).
  • How to make context menus for notification tray icons.
  • How to work with threads and manage its cycle time to avoid taxing the system's hardware more than necessary.

Caps Lock LED

Some newer laptops don't have an LED on their keyboard's caps lock. Since this is a minor inconvenience, it doesn't necessarily merrit modifying the keyboard itself to add that little notifying toggle LED. So the next best thing would be having an icon in your notification tray that updates to show you when your caps lock is either toggled on or off.
Most modern notification tray icons are monochrome, with transparent backgrounds. The icons in this program follow that trend, being just:
a white hollow circle for the "off" state
Image of "off" state
and the same circle, but filled in, for the "on" position.
Image of "on" state
These .ico files are stored in ...\Caps Lock LED\bin\Debug and can be changed to your preferance. Just make sure to keep the same file names, or else the program won't find your new .ico files.
This program checks the status of your caps lock key every 100 milliseconds (10 times a second) - a nice balance between having the icon be accurate and the program not taxing your system too much. If you wish to change that timing, go into HiddenForm.cs and change the value inside line 93's .Sleep() method to whatever suits your needs.
If you wish to have this program run on startup, create a shortcut of Caps Lock LED.exe from the ...\Caps Lock LED\bin\Debug folder, and move that shortcut to C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp.
If you wish to quit the program, simply right click on the icon, and hit quit.