Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

commented Mar 22, 2018

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

Empty outline cursor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.