Expand description
Type any Unicode string on macOS, regardless of keyboard layout.
The string is posted directly as a keyboard event via CoreGraphics
(CGEventKeyboardSetUnicodeString), so the active keyboard layout is
never consulted — characters that no key combination can produce still
arrive at the frontmost app.
if !typechar::has_permission() {
typechar::request_permission(); // prompts the user via System Settings
}
typechar::type_string("¯\\_(ツ)_/¯")?;The calling process needs macOS Accessibility permission (System Settings
→ Privacy & Security → Accessibility); without it type_string returns
TypeError::PermissionDenied instead of silently typing nothing.
Enums§
Functions§
- decode_
codepoint - Decode a hex codepoint like “20ac” or “U+20AC” into a char.
- has_
permission - Whether the calling process may post keyboard events.
- parse_
args - Parse argv (excluding argv[0]) into an Action.
- request_
permission - Ask macOS to prompt the user to grant this process Accessibility permission (opens System Settings). Returns whether permission is held.
- type_
string - Type
textinto the frontmost application, bypassing the keyboard layout. - utf16_
chunks - Split text into UTF-16 chunks of at most
max_unitscode units, never splitting a surrogate pair across chunks.