Skip to content

Instantly share code, notes, and snippets.

@akaleeroy
Last active March 23, 2024 09:48
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save akaleeroy/23a6d0323f3ae0ff4e2bc7962534cc0c to your computer and use it in GitHub Desktop.
Save akaleeroy/23a6d0323f3ae0ff4e2bc7962534cc0c to your computer and use it in GitHub Desktop.
Cursor Language Indicator - Reflect keyboard layout changes in mouse pointer look.
#SingleInstance, force
#Persistent
Menu, Tray, NoIcon
bool := 1
; Reference: Language Identifier Constants and Strings
; https://msdn.microsoft.com/en-us/library/windows/desktop/dd318693(v=vs.85).aspx
lang := 0x4090409 ; English
; Paths for Windows Black (system scheme) cursors
; May vary between Windows versions, make sure these exist
blackIBeam = `%SystemRoot`%\cursors\beam_r.cur
blackArrow = `%SystemRoot`%\cursors\arrow_r.cur
blackAppStarting = `%SystemRoot`%\cursors\busy_r.cur
blackCrosshair = `%SystemRoot`%\cursors\cross_r.cur
blackHelp = `%SystemRoot`%\cursors\help_r.cur
blackWait = `%SystemRoot`%\cursors\wait_r.cur
blackSizeNESW = `%SystemRoot`%\cursors\move_r.cur
SetTimer, CheckLang, 200
CheckLang:
Suspend, Permit
if(lang = Format("0x{:x}", DllCall("GetKeyboardLayout", "Int", DllCall("GetWindowThreadProcessId", "Int", WinActive("A"), "Int", 0)))) {
if(bool) {
; English keyboard layout
; Reset to default (empty string)
RegWrite, REG_EXPAND_SZ, HKEY_CURRENT_USER, Control Panel\Cursors, IBeam,
RegWrite, REG_EXPAND_SZ, HKEY_CURRENT_USER, Control Panel\Cursors, Arrow,
RegWrite, REG_EXPAND_SZ, HKEY_CURRENT_USER, Control Panel\Cursors, AppStarting,
RegWrite, REG_EXPAND_SZ, HKEY_CURRENT_USER, Control Panel\Cursors, Crosshair,
RegWrite, REG_EXPAND_SZ, HKEY_CURRENT_USER, Control Panel\Cursors, Help,
RegWrite, REG_EXPAND_SZ, HKEY_CURRENT_USER, Control Panel\Cursors, Wait,
RegWrite, REG_EXPAND_SZ, HKEY_CURRENT_USER, Control Panel\Cursors, SizeNESW,
; Make it stick
setCursors()
bool := False
}
} else {
if(!bool) {
; Non-English keyboard layout
; Set black cursors individually because you can't set the scheme
RegWrite, REG_EXPAND_SZ, HKEY_CURRENT_USER, Control Panel\Cursors, IBeam, %blackIBeam%
RegWrite, REG_EXPAND_SZ, HKEY_CURRENT_USER, Control Panel\Cursors, Arrow, %blackArrow%
RegWrite, REG_EXPAND_SZ, HKEY_CURRENT_USER, Control Panel\Cursors, AppStarting, %blackAppStarting%
RegWrite, REG_EXPAND_SZ, HKEY_CURRENT_USER, Control Panel\Cursors, Crosshair, %blackCrosshair%
RegWrite, REG_EXPAND_SZ, HKEY_CURRENT_USER, Control Panel\Cursors, Help, %blackHelp%
RegWrite, REG_EXPAND_SZ, HKEY_CURRENT_USER, Control Panel\Cursors, Wait, %blackWait%
RegWrite, REG_EXPAND_SZ, HKEY_CURRENT_USER, Control Panel\Cursors, SizeNESW, %blackSizeNESW%
; Make it stick
setCursors()
bool := True
}
}
return
setCursors() {
SPI_SETCURSORS := 0x57
result := DllCall("SystemParametersInfo", "UInt", SPI_SETCURSORS, "UInt", 0, "UInt", 0, "UInt", 0)
}

Cursor Language Indicator

Windows AutoHotkey Usability

Reflect keyboard layout changes in mouse pointer look.

Cursor Language Indicator Demo

Description

When typing in English cursors are default white. When switching to another keyboard layout the cursor turns black to remind you. The Windows language bar can be hidden (it wasn't near the typing anyway) and you can switch languages with Left Alt+Shift

Usage

Run with AutoHotkey.
Different versions of Windows may have different cursor paths/filenames. Make sure they match.

Reference

Adapted from code posted in these AutoHotkey forum threads :

If current keyboard layout is english then - AutoHotkey Community
How to change the cursor image? - AutoHotkey Community

To set up another default language look up its hexadecimal locale identifier here:
Language Identifier Constants and Strings (Windows)

@akaleeroy
Copy link
Author

⚠️ If you reset cursors by assigning an empty string some screen recording software may register it as only an empty outline!

Empty outline cursor

@Enlight432
Copy link

Please apply this difference to the mouse pointer in the selected mode

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment