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

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

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.

Autohotkey window showing toggle status

#SingleInstance
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.

key_state := {}
; get initial state
key_state["Caps On"] := GetKeyState("CapsLock", "T")
key_state["Num Off"] := not GetKeyState("NumLock", "T")
key_state["Scroll Off"] := GetKeyState("ScrollLock", "T")
manage_gui_state(key_state)

ScrollLock::
key_state["Scroll Off"] := not GetKeyState("ScrollLock", "T")
if(key_state["Scroll Off"])
	SetScrollLockState, on    
else
	SetScrollLockState, Off	
manage_gui_state(key_state)
return

CapsLock::
key_state["Caps On"] := not GetKeyState("CapsLock", "T")
if(key_state["Caps On"])
  SetCapsLockState, on    
else
	SetCapsLockState, Off	
manage_gui_state(key_state)
return

NumLock::
; warning needed if num lock is about to be turned off
key_state["Num Off"] := GetKeyState("NumLock", "T")
if(key_state["Num Off"])
  SetNumLockState, Off    
else
  SetNumLockState, On
manage_gui_state(key_state)
return

get_message(key_state){  
  message :=""
  For k,v in key_state
    if(v=true)
      message:=message . k . "`n"
  message := SubStr(message, 1 , -1)
  return message  
}

warning_needed(key_state){
  warn:=false  
  For k,v in key_state
  {    
    if (v = true)
    {
      warn:=true
      break
    }
  }  
  return warn
}

manage_gui_state(key_state){
  if(warning_needed(key_state)){
    message:=get_message(key_state)
    show_gui("Toggle Status", message)
  }
  else
  {    
    Gui, Destroy	
  }  
}

show_gui(title, message){  
  Gui +LastFoundExist
  if WinExist()
    Gui, Destroy
  Gui +E0x20 ; click through  
  Gui, -SysMenu +ToolWindow +AlwaysOnTop
  Gui, Color, Black
  Gui, Font, cwhite
  Gui, Add, Text, x10 y10 w90 Center, %message%
  WinGet, active_window, PID, A ; NoActivate seems to have no effect, using a hack
  Gui, Show, % "x" A_ScreenWidth - 180 "y" A_ScreenHeight - 130 AutoSize NoActivate, %title%
  WinSet, Transparent, 200 , %title%
  if WinExist("ahk_pid " active_window)
    WinActivate ; use the window found above  
}

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:-

Gui, 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:

Gui +E0x20 ; click through

Put a semi-colon before it like so:

;Gui +E0x20 ; click through

Adjust transparency

In the line

WinSet, 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:

Gui, Color, Black
Gui, Font, cwhite

The color options available can be found here.

Leave a Comment

Your email address will not be published. Required fields are marked *