Unix/Linux

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • hbb"SendKeys" equivalent in Linux

    6 answers - 283 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    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?
    Thanks.
  • No.1 | | 604 bytes | |

    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.

    is just to use an input file:

    yourapp < yourfileofkeystrokes

    Another is to use Expect (see )
    which is usually the easiest way to do anything complicated.

    Perl, Python etc. include the ability to open another program just as
    you'd open a file and send keystrokes to it.
  • No.2 | | 885 bytes | |

    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.

    is just to use an input file:

    yourapp < yourfileofkeystrokes

    That's limited to console programs. And if the program messes
    around with the console settings I's getting challenging.

    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.

    Wolfgang Draxinger
  • No.3 | | 1969 bytes | |

    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. 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?
  • No.4 | | 572 bytes | |

    Dances With Crows <danSPANceswitTRAPhcrows@gmail.comwrote:
    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?

    wmctrl might be able to do this. See

    There are links to a bunch of other utilities there, at least some of
    which should help.
  • No.5 | | 1189 bytes | |

    Mon, 25 Jul 2005 20:12:49 +0000 (UTC), Jeremiah DeWitt Weiner
    staggered into the Black Sun and said:
    Dances With Crows <danSPANceswitTRAPhcrows@gmail.comwrote:
    >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?

    wmctrl might be able to do this. See

    Ah yes. "wmctrl -l -p" lists all windows that the window manager is
    managing, and the PIDs that are the PIDs of the windows' controlling
    process. At least, it does this if the window manager is kwin and
    you're running mostly KDE apps and Firefox. xterm doesn't have its PID
    listed. YMMV on this. I haven't figured out how to get wmctrl to say
    which window currently has the input focus. But wmctrl would certainly
    be a good place to start looking.

    There are links to a bunch of other utilities there, at least some of
    which should help.

    This is probably good advice. Thanks for reminding me about wmctrl; I
    used it once to do something and promptly forgot about it
  • No.6 | | 1154 bytes | |

    I just found xmacro (on Sourceforge.net) to be a real *KEEPER* in my
    box of tools on Linux now that I have figured it out. The docs kind of
    aren't there, so the technique with it is:

    $ vi /etc/apt/sources.list
    {Edit your apt sources so that you can use a source that has xmacro
    packaged for your particular distro. For instance, on Ubuntu, I have to
    uncomment the "universe" setting in order to see the xmacro Debian
    package. , you can always download this from SourceForge.net.}
    $ apt-get update
    $ apt-get install xmacro
    $ xmacrorec2 my.macro
    {Press [Scroll Lock] key. Type your keystrokes and do your optional
    mouse events that you want to record. Press [Scroll Lock] key again to
    stop the recording.}
    $ vi my.macro
    {Edit this file and remove out any lines that you don't want or need.}
    $ cat my.macro | xmacroplay ":0.0"

    By doing this, for instance, I was able to record CTRL+ALT+d, which was
    the Show Desktop feature in GNME. I could then attach this to a
    launcher and make a better looking Show Desktop button, which I
    describe here:

    #post279697

Re: hbb"SendKeys" equivalent in Linux


max 4000 letters.
Your nickname that display:
In order to stop the spam: 9 + 9 =
QUESTION ON "Unix/Linux"

EMSDN.COM