Skip to content

Fill a form in a native app without stealing focus

Goal. An agent fills in a form in TextEdit, a settings dialog or any native app, and you keep typing in your own window the whole time.

Text typed into TextEdit while the terminal keeps focus
aos key type --app=TextEdit

Type into the app by name. Nothing changes focus:

Terminal window
aos key type "Jane Doe" --app=TextEdit
aos key press tab --app=TextEdit
aos key type "jane@example.com" --app=TextEdit
aos key press enter --app=TextEdit

Check the text actually landed:

Terminal window
aos key type "hello" --app=TextEdit --verify

--verify reads the text back from the app’s text field and exits 1 if it did not arrive.

Some apps only accept input when they are focused. Hand focus over for the duration of the command and get it back after:

Terminal window
aos key type "hello" --app=Chrome --focus
The verify step reads the text back from TextEdit
aos key type --app=TextEdit --verify

Fill in the name field in TextEdit with Jane Doe and the email with jane@example.com, without taking my focus. Verify the text arrived.

  • Key names are lower case with +. cmd+shift+s, ctrl+a, enter, tab, esc.
  • --app posts events to that window. The app must be running with a window. Exit 3 means no window matched.
  • Focus-free input does not work in every app. Some apps ignore posted events. Try --focus before concluding the field is unreachable.
  • Point at the right field first. Combine with aos mouse click --app=TextEdit --find="Email" to land in the field by its label.