DEV Community

Cover image for Light Indicator Status with AutoHotKey
Camilo Martinez
Camilo Martinez

Posted on • Edited on

Light Indicator Status with AutoHotKey

Languages: [🇪🇸] Español - [🇺🇸] English


If you don't have light indicators on your keyboard or device. AutoHotKey can rescue us with a simple script to know the state of modifier keys.

Create a file called key-indicator.ahk with this script:

 ~*CapsLock:: ~*NumLock:: ~*ScrollLock:: ~*Insert:: Sleep, 10 ; drastically improves reliability on slower systems msg := "" msg := msg "Caps: " (GetKeyState("CapsLock", "T") ? "ON" : "OFF") "`n" msg := msg "Num: " (GetKeyState("NumLock", "T") ? "ON" : "OFF") "`n" msg := msg "Scroll: " (GetKeyState("ScrollLock", "T") ? "ON" : "OFF") "`n" msg := msg "Insert: " (GetKeyState("Insert", "T") ? "ON" : "OFF") ToolTip, %msg% Sleep, 750 ; SPECIFY DISPLAY TIME (ms) ToolTip ; remove return ``` Save the file and open it with AutoHotkey. You will get a screen notification status near your mouse pointer. ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ls81ne640b7hoeoij276.png) --- If you are using the `CapsLock` as `Backspace` and `CapsLock` enabled/disable with `Alt` key. ```cpp CapsLock::Backspace !CapsLock::CapsLock ; Alt+CapsLock -> Enable/Disable Caps Lock ``` Change the first line from `~*CapsLock::` to `~*!CapsLock::` on script file. --- **Sources:** - [AHK Board - Another on screen caps lock indicator](https://autohotkey.com/board/topic/100990-another-on-screen-caps-lock-indicator/) --- **That’s All Folks!** **Happy Coding** 🖖 [![beer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mkgsx4aw6qn9i9ax6as9.png)](https://github.com/sponsors/deinsoftware) 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)