Re: "SendKeys" equivalent in Linux

From: Dances With Crows (danSPANceswitTRAPhcrows_at_gmail.com)
Date: 07/25/05


Date: Sun, 24 Jul 2005 19:52:25 -0500

On Mon, 25 Jul 2005 02:10:07 +0200, Wolfgang Draxinger staggered into
the Black Sun and said:
> Tony Lawrence wrote:
>> EKurtz99@aol.com wrote:
>>> In Windows it is possible to control one application from another by
>>> sending keystrokes to the buffer for that app. The technique is
>>> limited, of course, by what you can do via the keyboard in the
>>> driven app. Is there an equivalent in Linux?
>> Several. One is just to use an input file: yourapp <
>> yourfileofkeystrokes
> That's limited to console programs.

Aye.

> In X11 it's quite easy possible to send virtual keystrokes. However I
> never did it so far and it's been quite a while since I've browsed the
> Xlib reference. But the Xlib has definitely functions you want.

You don't need to mess around at that low of a level. There's a program
called "xmacroplay" that can send fake keystroke and mouse events to the
X server. http://xmacro.sourceforge.net/ , the syntax for sending stuff
is a little verbose but easily understandable.

The main problem with xmacroplay is that it sends key events to the
entire X server, not an arbitrary window. Events sent to the entire X
server are usually sent to the currently active window (if they're
normal keys, or mouse events in the currently active window) or the
window manager (if they're special key combinations or mouse events
outside the currently active window) or X itself (Ctrl-Alt-F?,
Ctrl-Alt-+/- , Ctrl-Alt-Bkspace).

It'd certainly be possible to use xmacroplay to send "Alt+Tab" to the
window manager until the proper window was active, but that'd require a
bit of communication that I don't know if X provides. So: Is it
possible to query X in some way and find the title of the currently
active window? Something with "xwininfo | grep $TITLE" , maybe?

-- 
Matt G|There is no Darkness in Eternity/But only Light too dim for us to see
Brainbench MVP for Linux Admin /    mail: TRAP + SPAN don't belong
http://www.brainbench.com     /
-----------------------------/        This space sort of for rent.


Relevant Pages

  • Re: Help with Active Windows Border and Active Toolbar Colors
    ... >then those color settings have no effect, as the window components are drawn with bitmaps rather than color fill. ... >> 1 - When I go into the Display Properties applet and try to adjust the ... >> colors displayed in the Active Title Bar, ... >> Active Window Border to Red, again it displays correctly in the ...
    (microsoft.public.windowsxp.customize)
  • Re: ActiveWindow broken in Word 2003?
    ... Thanks again Peter - you're absolutely right of course. ... Thus we support most combinations from 97 on WinNT to ... > say about the Window object. ... >>Word no longer seems able to track the active window ...
    (microsoft.public.word.vba.general)
  • Help with Active Windows Border and Active Toolbar Colors
    ... on my Compaq Presario S6900NX with an nVidia 5800 card. ... - When I go into the Display Properties applet and try to adjust the ... Active Window Border to Red, again it displays correctly in the ...
    (microsoft.public.windowsxp.customize)
  • Re: Inserting a string into an application
    ... a different one for each of the applications ... in that it just blindly sends keystrokes to ... likely become the active window and get some or all of the keystrokes. ...
    (microsoft.public.scripting.vbscript)
  • Re: Windows Programm starten
    ... Integer value indicating the appearance of the program's window. ... An application should specify this flag when displaying the window for the first time. ... Activates the window and displays it as a minimized window. ... The active window remains active. ...
    (microsoft.public.de.fox)