nkb send
Type one value of a pack into the field that has the keyboard focus. On Windows.
nkb send <pack> [--index N] [--delay S] [--clear]
How do I use it?
Name the pack and, with --index, which value. The command waits three seconds by default so you can click into the field, then types the value there:
$ nkb send magic-values --index 2 --delay 3
The value goes to the focused window, not to standard output, and everything the command says is on standard error. Add --clear to clear the current line of the field first with Home, Shift+End and Delete, the way the palette does by default. Without it, the only keys sent are the value’s own characters.
When does it refuse?
It refuses rather than guesses, and every refusal ends with exit code 4:
- while Ctrl, Alt, Shift or Win is held on the keyboard, after waiting up to two seconds for them to come up, because the value would turn into shortcuts,
- in a window running with higher privileges than
nkb, such as an application started as administrator, because Windows would drop the keystrokes without a word, - when the keyboard focus is on a button, a link, a list item or a page that is not editable, because keys there act on that control.
Where it cannot tell what has the focus, it sends. With --clear it clears only a focus it can confirm is a text field, and never a terminal, where those keys go to the program running in it. When it skips the clearing it says so, and the value goes in on top of what was there.
Can I stop it?
Press Escape. Nothing more is typed, the command says how much of the value arrived, and it exits with 4. Escape belongs to the command only while it types. Before and after, the key is the application’s.
Does it work on macOS and Linux?
Not yet. There the command says that it has no way to deliver keystrokes, and exits with 4. Honest limits says more.
Options
Exit codes
This command's help names no exit codes of its own. The numbers mean the same for every command: Exit codes
The help, as the program prints it
What nkb send --help prints, from nkb 0.1.0.
nkb send - type one value into the focused field
Usage:
nkb send <pack> [--index N] [--delay S] [--clear]
Put one value of a pack into whatever field has the keyboard focus.
Options:
--index N which value, counting from 1 in the pack's own order
(default: 1). The order of values is the order of testing.
--delay S seconds to wait first, so you can focus the target
(default: 3). Use 0 when something else focuses it.
--clear press Home, Shift+End, Delete first, clearing the current
line of the field. Never selects beyond the line, so a
multi-line field keeps its other lines. Without this switch
the only keys sent are the value's own characters.
-h, --help Show this help and exit with 0
The value goes to the focused window, not to standard output.
Everything you read here is on standard error.
Nothing is sent while Ctrl, Alt, Shift or Win is held on the keyboard:
the command waits up to two seconds for them to come up, then refuses.
Nothing is sent to a window running with higher privileges than nkb,
such as an application started as administrator: the system would drop
the keystrokes without a word, so the command refuses and exits with 4.
Nothing is sent when the keyboard focus is on a button, a link, a list item
or a page that is not editable: keys there act on that control, so the
command refuses and exits with 4. Where it cannot tell, it sends.
Press Escape to stop a send in progress: nothing more is typed, the command
says how much arrived and exits with 4. Escape belongs to the command only
while it types - before and after, the key is the application's.