java_send_keys
Sends keyboard shortcuts such as Alt+Y or Ctrl+Shift+S to the focused Java window; focus the target window first if the chord appears to do nothing.
Instructions
Send a keyboard shortcut — alt+y, ctrl+shift+s — to the window.
Use it for an action the application only exposes as a chord: a menu accelerator, a toolbar shortcut, a keystroke a canvas-drawn control listens for.
Nothing is focused and nothing is clicked. The chord goes to whichever window currently has the keyboard focus. That is deliberate on pyjab's side: clicking a control to focus its window would activate that control, and a shortcut usually exists to avoid exactly that.
So if a call seems to do nothing, the window probably does not have focus — and
attaching does not focus it (measured in pyjab#180). Call
java_focus_window(session_id=...) first and read what it reports: it says whether the
window came forward, which is the fact this tool needs. (Before that tool existed
this reply said to click something harmless first; that workaround is gone from the
shipped text, because it activated whatever it landed on and went through a locator
that could have gone stale — which is the thing a shortcut exists to avoid.)
Chords are written with + between key names and are case-insensitive: ctrl, alt,
shift, tab, enter, esc, spacebar, the arrow keys, and single letters or
digits. Names may be written in any case; the function keys (F1–F24) and escape
as another spelling of esc need pyjab 1.12.1, and plus for a literal + needs
1.12.2. A name that is not a key is an error rather than a silent no-op — a wrong
chord acts on somebody else's application and cannot be taken back.
This needs pyjab 1.11.0, which released JABDriver.send_keys
(gaozhao1989/pyjab#168 went in after 1.10.0). The call is probed rather than assumed,
like every pyjab capability here: an install below the pin is told which release has
the method instead of raising an AttributeError.
Args: session_id: From java_attach_window. keys: The chord, such as "alt+y".
Returns: What was sent, and the reminder that a shortcut's effect has to be looked for — this tool cannot see what the application did with it.
Errors:
is_error for an unknown session, a chord whose key names pyjab does not
recognise (with the name it did not recognise), or a pyjab below the pin — which
names the release that has the API and what to do instead.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"session_id": "<session_id>",
"keys": "<keys>"
},
"name": "java_send_keys"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keys | Yes | ||
| session_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |