Contact Us

Alerts for caps lock, num lock, and scroll lock in Windows 10

Reading Time: 3 min

Tags:  Windows

If your keyboard or laptop does not have indicators for caps, num or scroll keys you might want to consider a software-based solution.

Contents

Audio Alert

Start Menu ➾ Settings ➾ Ease of Access ➾ Keyboard

In the **Toggle Keys **section, choose the option Play a sound whenever you press Caps lock, Num lock or Scroll lock.

Enabling audio alert for toggle keys

Visual Alert

It is not possible to have visual alerts for toggle keys alone but they can be enabled for all audio alerts. This method has two limitations:-

  1. Visual alerts work only if you have enabled audio alerts first.
  2. Visual alerts will be shown for all audio alerts.

Steps:

Start Menu ➾ Settings ➾ Ease of Access ➾ Audio

In the Show audio alerts visually section, choose the type of alert you want.

Enabling visual alert for audio alert

Key status indicator using Autohotkey

Here is an Autohotkey script for showing the status of caps lock, scroll lock, and num lock keys. A small status window is shown if caps are on, or if scroll and numbers are off. The window is click-through and semi-transparent.

 1#SingleInstance
 2#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
 3SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
 4
 5key_state := {}
 6; get initial state
 7key_state["Caps On"] := GetKeyState("CapsLock", "T")
 8key_state["Num Off"] := not GetKeyState("NumLock", "T")
 9key_state["Scroll Off"] := GetKeyState("ScrollLock", "T")
10manage_gui_state(key_state)
11
12ScrollLock::
13key_state["Scroll Off"] := not GetKeyState("ScrollLock", "T")
14if(key_state["Scroll Off"])
15	SetScrollLockState, on    
16else
17	SetScrollLockState, Off	
18manage_gui_state(key_state)
19return
20
21CapsLock::
22key_state["Caps On"] := not GetKeyState("CapsLock", "T")
23if(key_state["Caps On"])
24  SetCapsLockState, on    
25else
26	SetCapsLockState, Off	
27manage_gui_state(key_state)
28return
29
30NumLock::
31; warning needed if num lock is about to be turned off
32key_state["Num Off"] := GetKeyState("NumLock", "T")
33if(key_state["Num Off"])
34  SetNumLockState, Off    
35else
36  SetNumLockState, On
37manage_gui_state(key_state)
38return
39
40get_message(key_state){  
41  message :=""
42  For k,v in key_state
43    if(v=true)
44      message:=message . k . "`n"
45  message := SubStr(message, 1 , -1)
46  return message  
47}
48
49warning_needed(key_state){
50  warn:=false  
51  For k,v in key_state
52  {    
53    if (v = true)
54    {
55      warn:=true
56      break
57    }
58  }  
59  return warn
60}
61
62manage_gui_state(key_state){
63  if(warning_needed(key_state)){
64    message:=get_message(key_state)
65    show_gui("Toggle Status", message)
66  }
67  else
68  {    
69    Gui, Destroy	
70  }  
71}
72
73show_gui(title, message){  
74  Gui +LastFoundExist
75  if WinExist()
76    Gui, Destroy
77  Gui +E0x20 ; click through  
78  Gui, -SysMenu +ToolWindow +AlwaysOnTop -Caption
79  Gui, Color, Black
80  Gui, Font, cwhite
81  Gui, Add, Text, x10 y10 w90 Center, %message%
82  WinGet, active_window, PID, A ; NoActivate seems to have no effect, using a hack
83  Gui, Show, % "x" A_ScreenWidth - 180 "y" A_ScreenHeight - 130 AutoSize NoActivate, %title%
84  WinSet, Transparent, 200 , %title%
85  if WinExist("ahk_pid " active_window)
86    WinActivate ; use the window found above  
87}

Configure the script

The script may have to be configured, especially the position of the window.

Change window position

The statement which sets the position of the window is this:-

1Gui, Show, % "x" A_ScreenWidth - 180 "y" A_ScreenHeight - 130 AutoSize NoActivate, %title%

Here A_ScreenWidth and A_ScreenHeight represent the horizontal and vertical resolution of your screen. Change the value which is being subtracted from A_ScreenWidth and A_ScreenHeight to change the position of the window.

Disable click-through

Comment out the line:

1Gui +E0x20 ; click through

Put a semi-colon before it like so:

1;Gui +E0x20 ; click through

Adjust transparency

In the line

1WinSet, Transparent, 200 , %title%

set a value between 0 and 255. 0 makes the window invisible, 255 makes it opaque.

Change Color

Change the color in the following lines:

1Gui, Color, Black
2Gui, Font, cwhite

The color options available can be found here.

Share