I tried using the xdotool commandline on a Chrome window in Debian, typically by doing:
sleep 2 && xdotool type "2"
# Switch to the Chrome window and focus on the relevant text field
# before the 2 seconds timer above runs out; "2" should be auto-written.
This mostly works, except in certain fields that do special event handling. A good example for this is the Google Search timer:
- Doing the procedure above to write 2 in the Google Search bar works, but
- When I search "timer" on google.com, I get the special timer answer, which contains a special field allowing users to change the timer values (numbers only).
While typing "2" with my regular keyboard works just fine, using xdotool as above (which should use XTEST) does not work (nothing happens). Sending Tab instead of 2 does work though (the field loses focus).
Note: I noticed that this happened on other number fields as well, all of which have the same other specificity that they do not work with e.g. the French AZERTY keyboard layout that requires pressing Shift to get numbers. I thus tried "xdotool key 2" in US layout and also "xdotool key shift+2" in FR layout, none of which worked.
UPDATE: I tried on 3 laptops:
- Google Chrome on Debian, FR layout by default,
- Firefox on Ubuntu, FR layout by default,
- Firefox on Ubuntu, US layout by default (no other layout ever used)
and the bug reproduces on 1. and 2. but not 3., thus suggesting that even when I switch the layout back to US in 1. and 2., the default layout or keyboard configuration still messes up with xdotool's ability to simulate text being typed.