DEV Community

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

Posted on • Edited on

1 2

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/)

---

**Thats 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

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay