Muitos programas não aceitam toques de tecla quando não têm o teclado - o que certamente faz algum sentido.
Mas você não precisa usar "windowactivate", "windowfocus" funciona e não traz a janela para frente, etc.:
xdotool windowfocus 8392809 key p
Além disso, você pode simplificar seu comando para uma linha usando o comando sleep
de xdotool
xdotool key p sleep 0.5 key s
ou usando a opção --delay
com o comando key
.
Como plano de fundo: os comandos que você tentou são muito semelhantes, mas têm uma diferença técnica, explicada em man xdotool
:
SENDEVENT NOTES
If you are trying to send key input to a specific window, and it does not appear to be working, then it's
likely your application is ignoring the events xdotool is generating. This is fairly common.
Sending keystrokes to a specific window uses a different API than simply typing to the active window. If you
specify 'xdotool type --window 12345 hello' xdotool will generate key events and send them directly to window
12345. However, X11 servers will set a special flag on all events generated in this way (see
XEvent.xany.send_event in X11's manual). Many programs observe this flag and reject these events.
It is important to note that for key and mouse events, we only use XSendEvent when a specific window is
targeted. Otherwise, we use XTEST.
Some programs can be configured to accept events even if they are generated by xdotool. Seek the documentation
of your application for help.
Specific application notes (from the author's testing): * Firefox 3 seems to ignore all input when it does not
have focus. * xterm can be configured while running with ctrl+leftclick, 'Allow SendEvents' * gnome-terminal
appears to accept generated input by default.