Skip to content
ts33krPublic
forked from holgertkey/ccaps

About

Lightweight Windows utility to repurpose Caps Lock for instant keyboard layout switching

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

93 Commits

Folders and files

Repository files navigation

CCaps Layout Switcher v0.11.0

A lightweight Windows keyboard layout switcher that repurposes the Caps Lock key for quick layout switching with country-specific filtering and configuration persistence.

Features

  • Caps Lock → Layout Switch: Press Caps Lock to cycle through keyboard layouts
  • Country Code Filtering: Choose specific layouts to switch between (e.g., English ↔ German)
  • Shift + Caps Lock → Caps Lock: Hold Shift and press Caps Lock to toggle Caps Lock functionality
  • Optional Visual Indicator: Scroll Lock LED shows the current layout when enabled; disabled by default
  • Verified Switching: Checks that the window actually switched; optional Win+Space fallback is disabled by default
  • Fullscreen Passthrough: Native Caps Lock input in fullscreen and borderless fullscreen apps; enabled by default and configurable
  • Background Mode: Runs silently in the background
  • Auto-startup: Automatically starts with Windows
  • Configuration Persistence: Remembers your layout preferences
  • Low Resource Usage: Minimal CPU and memory footprint
  • No Dependencies: Single executable file

Installation

Option 1: Build this fork from source

cargo install --git https://github.com/ts33kr/ccaps --locked

This will download, compile, and install the latest version of CCaps. The executable will be placed in your Cargo bin directory (usually ~/.cargo/bin/ or %USERPROFILE%\.cargo\bin\).

Option 2: Download Pre-built Binary

  1. Download the latest release from the Releases page
  2. Extract ccaps.exe to any folder (e.g., C:\Program Files\CCaps\)
  3. Run the program using command line options

Usage

Command Line Options

# Basic commands
ccaps              # Show interactive menu
ccaps -run         # Run in foreground mode (all layouts)
ccaps -enable      # Save settings + add to auto-startup + start now (all layouts)
ccaps -enable -de  # Same, with English/German
ccaps -disable     # Stop + remove from auto-startup + delete settings
ccaps -start       # Start in background now (saved settings), auto-startup untouched
ccaps -start -de   # Start in background now with English/German (not saved)
ccaps -stop        # Stop background process only (settings and auto-startup kept)
ccaps -status      # Show status and available language codes
ccaps -help        # Show help information
ccaps -v           # Show version information

# Country-specific switching
ccaps -run -de     # English ↔ German switching
ccaps -run -de -fr # German ↔ French switching (no English)

Country Codes

Use ccaps -status to see all available language codes for your system. Common codes include:

Code Language Code Language Code Language
us English (US) ru Russian ua Ukrainian
gb English (UK) de German fr French
es Spanish it Italian pl Polish
pt Portuguese nl Dutch cz Czech
jp Japanese kr Korean cn Chinese

Key Bindings

Key Combination Action
Caps Lock Switch to next keyboard layout
Shift + Caps Lock Toggle Caps Lock on/off

Visual Indicator

The Scroll Lock LED can serve as a layout indicator when scroll_lock_indicator is set to true. It is disabled by default, with no indicator timer or Scroll Lock key events:

  • OFF (🔴) = English layout active
  • ON (🟢) = Non-English layout active

Quick Start Examples

1. Interactive Menu

ccaps

Shows a menu with all available options and current system status.

Available commands in interactive mode:

  • run - Run in foreground mode (all layouts)
  • run -de - Run with specific layouts (e.g., English ↔ German)
  • enable - Save settings, add to auto-startup and start now (all layouts)
  • enable -de - Same, with specific layouts
  • disable - Stop, remove from auto-startup and delete settings
  • start - Start in background now, without touching auto-startup
  • stop - Stop background process only (settings and auto-startup kept)
  • status - Show current status and available language codes
  • help - Show detailed help
  • menu - Show menu again
  • exit or e - Exit interactive menu

2. Switch Between English and German

ccaps -run -de

3. Switch Between Multiple Languages

ccaps -run -de -fr -es  # German ↔ French ↔ Spanish

4. Run in Background with English/German, Now and at Every Login

ccaps -enable -de

5. Run in Background Just for Now

ccaps -start       # saved settings (or all layouts)
ccaps -stop        # stop it again; nothing else changes

6. Check Available Languages and Current Configuration

ccaps -status

Output example:

CCaps Layout Switcher Status:
╞══════════════════════════════════════════════════════════════╡
Background process: RUNNING ✓
Auto-startup:       ENABLED ✓
Startup command:    "C:\Program Files\CCaps\ccaps.exe" --background -de
Configuration file: EXISTS ✓
Config path:        C:\Program Files\CCaps\ccaps-config.json
Saved country codes: de

Available keyboard layouts:
┌─────┬──────────────────────────────────────┬─────────────────┐
│ Code│ Language                             │ Status          │
├─────┼──────────────────────────────────────┼─────────────────┤
│ -us │ English (United States)              │ CURRENT ✓       │
│ -ru │ Russian                              │ Available       │
│ -ua │ Ukrainian                            │ Available       │
│ -de │ German                               │ Available       │
└─────┴──────────────────────────────────────┴─────────────────┘

Usage examples:
  ccaps -run            # Run in foreground mode (cycle through all layouts)
  ccaps -run -de        # Switch between English and German
  ccaps -enable -de     # Run in background now and at every login (English/German)
  ccaps -start          # Run in background now, without auto-startup

Status: All systems operational ✓

Configuration Persistence

CCaps saves your layout preferences when you use -enable:

  • Configuration file: ccaps-config.json (stored in %LOCALAPPDATA%\CCaps\)
  • Typical location: C:\Users\<username>\AppData\Local\CCaps\ccaps-config.json
  • Auto-restore: Background process automatically loads saved preferences
  • JSON format: Human-readable configuration file

Example configuration file:

{
  "country_codes": ["de"],
  "version": "0.11.0",
  "win_space_fallback": false,
  "scroll_lock_indicator": false,
  "fullscreen_passthrough": true
}

Configuration Management

Both optional features default to false, including when loading an older configuration without these fields. Edit %LOCALAPPDATA%\CCaps\ccaps-config.json, then run ccaps -stop followed by ccaps -start to apply changes:

Setting Default When enabled
win_space_fallback false Send Win+Space if a direct layout request is ignored
scroll_lock_indicator false Update Scroll Lock at startup, after switches, and every 250 ms
fullscreen_passthrough true Leave Caps Lock untouched in fullscreen and borderless fullscreen apps

These settings apply to foreground, background, and interactive runs. Language arguments override only the selected layouts. -enable preserves existing feature settings when saving languages. -status reports all settings. With fallback disabled, applications that ignore direct requests must be switched using Windows' language selector or Win+Space manually.

Fullscreen passthrough checks the foreground window's client area against its monitor only when Caps Lock is pressed, without a watcher or polling timer. It also applies to fullscreen browsers and video players; ordinary maximized windows remain eligible for language switching. The press/release decision stays paired if focus changes while Caps Lock is held. Windowed games do not qualify. This does not establish anti-cheat compatibility.

Gaming and selected language pairs

To use Caps Lock for English/Russian switching while leaving Ukrainian available through Windows' normal language selector, keep all three layouts installed and run:

ccaps -enable -ru

The single ru filter includes English automatically; Ukrainian stays outside the Caps Lock cycle. Win+Space still offers all installed layouts. -enable saves the language selection, starts CCaps if needed, and adds its current executable path to Windows startup. Keep the executable in a permanent folder before enabling startup.

Recommended settings for fullscreen gaming are the defaults shown above: win_space_fallback: false, scroll_lock_indicator: false, and fullscreen_passthrough: true. This avoids synthetic Win+Space and Scroll Lock input and lets the game receive the original Caps Lock press and release. It does not unload the keyboard hook or recognize windowed games. Set fullscreen_passthrough to false if you want layout switching in fullscreen applications too.

The modified build has been tested successfully in normal windows and several Apex Legends matches on one Windows installation. This is a compatibility observation, not an assurance for every game or future anti-cheat update.

  • Saving: ccaps -enable -de saves the English/German preference
  • Auto-loading: The background process loads saved preferences at login and on ccaps -start
  • Temporary codes: ccaps -start -de uses English/German this time without saving it
  • Cleanup: ccaps -disable removes the configuration file; ccaps -stop keeps it
  • Status check: ccaps -status shows current configuration

How It Works

CCaps uses Windows low-level keyboard hooks to intercept Caps Lock key presses and redirect them to layout switching functionality. The program:

  1. Installs a system-wide keyboard hook
  2. Intercepts Caps Lock key events
  3. Cycles through selected keyboard layouts (filtered by country codes)
  4. Asks the focused window to switch its layout, then checks that it actually did
  5. If explicitly enabled, falls back to Win+Space when the window ignores the request
  6. If explicitly enabled, updates the Scroll Lock indicator from the actual layout
  7. Blocks the default Caps Lock behavior (unless Shift is held)
  8. Saves and restores layout preferences automatically

Applications That Ignore the Layout Request

Some applications don't handle the standard layout change request. CCaps checks the layout after every switch. By default, it reports a failed direct switch without injecting Win+Space. If win_space_fallback is explicitly enabled and the layout hasn't changed within 150 ms, CCaps presses Win+Space and re-reads the layout after each press until the target layout is reached.

  • In such applications a switch takes about 170–300 ms (depending on how many Win+Space presses are needed) instead of a few milliseconds
  • Win+Space cycles through all installed layouts, so CCaps may press it several times to reach the next selected one; you may briefly see the intermediate layouts
  • To avoid switching twice or triggering another shortcut, the fallback is skipped when the window is busy (not responding), when Shift, Ctrl, Alt or Win is held, when you press Caps Lock again, or when another window gets focus

Layout Selection Logic

  • No country codes: Cycles through all installed layouts
  • One country code: Switches between English and the specified language
  • Multiple country codes: Cycles through the specified languages only
  • English preference: If multiple layouts are specified, English is automatically included unless all specified layouts are non-English

Supported Languages

The layout detection works with all Windows keyboard layouts. The program automatically detects over 40 languages including:

  • English variants: US, UK, Australia, Canada, New Zealand, Ireland, South Africa
  • Cyrillic: Russian, Ukrainian, Bulgarian, Serbian, Belarusian
  • Western European: German, French, Spanish, Italian, Portuguese, Dutch
  • Nordic: Norwegian, Swedish, Danish, Finnish, Icelandic
  • Eastern European: Polish, Czech, Hungarian, Slovak, Romanian
  • Asian: Japanese, Korean, Chinese (Simplified/Traditional), Thai, Vietnamese
  • Middle Eastern: Arabic, Hebrew, Farsi

Advanced Usage

Background Process Management with Specific Layouts

# Run now and at every login with specific layouts (saved)
ccaps -enable -de         # English/German switching
ccaps -enable -de -fr     # German/French switching
ccaps -enable             # All layouts (default)

# Stop for now / start again; settings and auto-startup are kept
ccaps -stop
ccaps -start

# Remove CCaps from auto-startup and delete its settings
ccaps -disable

Interactive Menu with Configuration

ccaps
# Choose from menu:
# enable -de    # This saves the preference, adds auto-startup and starts in background
# run -de       # This only runs temporarily without saving
# e             # Quick exit from interactive menu

Registry Integration

The program stores startup configuration in:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Key: "CCaps Layout Switcher"
Value: "C:\Program Files\CCaps\ccaps.exe" --background -de

Status Monitoring

ccaps -status

Shows:

  • Background process status
  • Auto-startup configuration
  • Configuration file status and location
  • Saved country codes
  • All available keyboard layouts with country codes
  • Current active layout
  • Usage examples and recommendations

Building from Source

Prerequisites

  • Rust 1.70 or later
  • Windows 10/11
  • Visual Studio Build Tools (for linking)

Build Steps

git clone https://github.com/ts33kr/ccaps.git
cd ccaps
cargo build --release

The executable will be created at target/release/ccaps.exe.

Dependencies

  • winapi: Windows API bindings
  • ctrlc: Ctrl+C signal handling
  • serde: Serialization framework
  • serde_json: JSON serialization

Technical Details

  • Language: Rust
  • Version: 0.11.0
  • Windows APIs: WinAPI (winuser, winreg, synchapi, fileapi)
  • Hook Type: Low-level keyboard hook (WH_KEYBOARD_LL)
  • Registry: Uses HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
  • Configuration: JSON file in %LOCALAPPDATA%\CCaps\
  • Mutex: Global mutex prevents multiple instances
  • Layout Detection: Language ID extraction from HKL handles

Diagnostics in Foreground Mode

ccaps -run prints a line for every Caps Lock press, which helps to find applications where switching doesn't work as expected:

[10:42:13.517] us → ru  Switched: 6 ms · firefox.exe (MozillaWindowClass)
[10:42:15.004] ru → us  SwitchedByFallback: 2× Win+Space, 231 ms · Code.exe (Chrome_WidgetWin_1)
[10:42:16.100] us → ru  Switched late: applied after the 150 ms check, no Win+Space, 180 ms · idea64.exe (SunAwtFrame)
[10:42:17.250] us → ru  Failed: a modifier key is held, no Win+Space, 151 ms · app.exe (AppWindow) (+2 earlier press(es) skipped)
[10:43:01.002] Layout ru in Telegram.exe (Qt51517QWindowIcon), not switched by CCaps → Scroll Lock ON

Each line shows the time, the layouts, the outcome with its reason, how long the switch took, and the application (executable and window class):

  • Switched: the window applied the layout request
  • Switched late: the window applied it after the 150 ms check, so no Win+Space was needed (the application was busy)
  • SwitchedByFallback: the window ignored the request; the layout was reached with Win+Space
  • Unverified: CCaps can't tell whether the layout changed (e.g. the window isn't responding)
  • Failed: the layout was not changed; the reason says why
  • earlier press(es) skipped: rapid presses were merged, only the last one was carried out
  • not switched by CCaps: the layout changed in another way (Win+Space, the mouse, another window got focus) and the Scroll Lock indicator followed it

Known Limitations

  • Windows running as administrator: when an elevated window (e.g. cmd or regedit started "as administrator") has focus, Windows doesn't pass keyboard input to CCaps, which runs with normal rights. In such windows Caps Lock works as a regular Caps Lock and doesn't switch the layout. Switch the layout with Win+Space there.
  • Terminals that control Scroll Lock (mintty: Cygwin, MSYS2, Git Bash): mintty resets the Scroll Lock LED itself, so the indicator doesn't reflect the layout while a mintty window has focus. Layout switching works normally.
  • Applications that ignore the layout request: require manual layout selection by default. Optional Win+Space fallback can be enabled (see Applications That Ignore the Layout Request).

Troubleshooting

CCaps stops unexpectedly

Lifecycle diagnostics are saved in %LOCALAPPDATA%\CCaps\lifecycle.log, with one rotated previous log after approximately 1 MiB. They record startup, readiness, explicit stop requests, session-end messages, message-loop errors, and Rust panics. They do not record keys, typed text, or window titles, and use no polling timer. If CCaps exits without a final log entry, termination may have occurred outside its normal exit handling; the log alone cannot identify the source of an external termination.

Cancelled Windows shutdown or sign-out requests no longer stop CCaps: it stays active after WM_QUERYENDSESSION and only exits after a confirmed WM_ENDSESSION.

Caps Lock toggles Caps Lock in some windows

The window is probably running as administrator; see Known Limitations.

The Scroll Lock indicator doesn't match the layout

  • In mintty-based terminals (Cygwin, MSYS2, Git Bash) this is expected; see Known Limitations
  • First check that scroll_lock_indicator is enabled; it defaults to false
  • When enabled, the indicator follows the actual layout within a quarter of a second, also after switching with Win+Space or the mouse

Invalid Country Code Error

ccaps -run -zz
# Error: Unknown country codes: zz. Use 'ccaps -status' to see available codes.

Solution: Run ccaps -status to see all available country codes for your system.

Program doesn't start with Windows

# Check status
ccaps -status

# Re-enable startup
ccaps -enable -de   # or your preferred layout codes

Configuration not loading

  • Check if configuration file exists: ccaps -status
  • Restart background process: ccaps -stop then ccaps -start
  • Delete and recreate: ccaps -disable then ccaps -enable -de

Layout switching not working with specific codes

  • Ensure the specified keyboard layouts are installed in Windows
  • Check available codes with: ccaps -status
  • Verify layouts in Settings → Time & Language → Language → Preferred languages

Uninstall

# Stop the program and remove all traces
ccaps -disable

# Delete the executable file
del ccaps.exe

# Configuration file is automatically deleted by 'ccaps -disable'

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

See CHANGELOG.md for the full version history.

About

Lightweight Windows utility to repurpose Caps Lock for instant keyboard layout switching

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages