Skip to content

winput ​

Tool tools/live/winput.py (program, The running game). Build and run winput, which sends keys, mouse moves and clicks to a game from inside Wine.

Run it with ./gameframe run winput ARGS or python3 tools/live/winput.py. Source on GitHub.

Its own help ​

This is the help text in the tool itself, as ./gameframe tool winput prints it.

text
Build and run winput, which sends keys, mouse moves and clicks to a game from inside Wine.

Usage: winput.py build [--out FILE]             build winput.exe (32-bit Windows) with zig cc
       winput.py host [--out FILE]              build a --dry-run copy for this machine, for tests
       winput.py run [--wine WINE] [--prefix DIR] [--exe FILE] [--dry-run] STEP ...
       winput.py keys                           the key names winput knows

STEP is one of winput's steps, in order (tools/live/winput.c has them all):

  list | window TITLE | key NAME[:MS] | down NAME | up NAME | release | type TEXT |
  move DX DY | click X Y [right] | point X Y | button [right] | wait MS

  --hold MS before the steps sets how long `key` holds a key (default 50; 500 for a game at a
  low frame rate). Keys that `down` holds are released when winput ends. For a game that draws
  its own cursor, `point X Y wait 1000 button` clicks where `click` may miss.

  winput.py run --prefix derived/wine window "POD" wait 500 key enter key down:200 type abc

Why: macOS ignores input from a process without the Accessibility permission. Tools that drive
the desktop cannot see Wine's windows. winput runs inside the same Wine prefix as the game and
calls SendInput. Keys go as scancodes, which DirectInput reads. See
docs/knowhow/wine-input-without-accessibility.md.

Inputs: winput.c next to this file. `build` writes winput.exe (default: winput.exe in the current
folder). It needs zig. `run` builds winput.exe first when --exe is missing. Then it runs WINE
(default $WINE, else `wine` on PATH), with WINEPREFIX set to --prefix when given. The exit code
is winput's. It is 1 when a window is not found or an input was not sent, and 2 for a bad step.

It does not read the screen or record input. A game that draws its own cursor from DirectInput's
relative movement ignores `click` positions. Use `move` for such a game. Standard library only.

Named by ​

Skills: re-observe.

Code: Apache 2.0. Content: CC0 1.0. No game material: bring your own copy.