You are not logged in.

#1 2011-07-19 14:53:28

whoops
Member
Registered: 2009-03-19
Posts: 891

[solved] send keyboard event / key to specific background window?

Hi!

So... is this possible / how? I'd like to send keyboard events to a window in the background - maybe even in regular intervals. While I'm dong something else, in another window (or nothing).


Thx!

Last edited by whoops (2011-07-21 11:05:44)

Offline

#2 2011-07-19 15:00:36

SanskritFritz
Member
From: Budapest, Hungary
Registered: 2009-01-08
Posts: 1,923
Website

Re: [solved] send keyboard event / key to specific background window?


zʇıɹɟʇıɹʞsuɐs AUR || Cycling in Budapest with a helmet camera || Revised log levels proposal: "FYI" "WTF" and "OMG" (John Barnette)

Offline

#3 2011-07-21 09:23:33

whoops
Member
Registered: 2009-03-19
Posts: 891

Re: [solved] send keyboard event / key to specific background window?

Thanks!

But is there a way to send the input to a specific window / application (that might be in the background, on another desktop or something)?

(Without running the application in its own xserver?)

Last edited by whoops (2011-07-21 09:24:13)

Offline

#4 2011-07-21 09:36:38

my0pic
Member
From: Melbourne, Australia
Registered: 2008-05-23
Posts: 206

Re: [solved] send keyboard event / key to specific background window?

Have a look at xdotool. Use it to get the window id first, say for gimp

win=$(xdotool search --onlyvisible --class gimp | head -1)

then to send it a key combo

xdotool key --clearmodifiers --window $win Ctrl+q

or to switch to it

xdotool windowactivate $win

Offline

#5 2011-07-21 11:05:16

whoops
Member
Registered: 2009-03-19
Posts: 891

Re: [solved] send keyboard event / key to specific background window?

Thanks, xdotools seems to do the job a lot better!

Keyboard works fine. I didn't manage to send mouse events yet, but that compiz might be at fault there - going to try again later.

Offline

#6 2011-07-21 12:29:31

SanskritFritz
Member
From: Budapest, Hungary
Registered: 2009-01-08
Posts: 1,923
Website

Re: [solved] send keyboard event / key to specific background window?

Actually I'm thinking, maybe there is a totally another (better?) way to do what you want. I usually find that automatizing tasks in linux differs very much from the windows experinece, most of the times scripting is the most powerful and easy way of doing things. So if you describe to us what you want to accomplish, maybe some experienced linux gurus would give you some advices that sets you off course from sending keys and mouse events. I used to do that in windows with autohotkey, but now in linux there was no need for that so far ever, except for using system wide abbreviations with autokey.


zʇıɹɟʇıɹʞsuɐs AUR || Cycling in Budapest with a helmet camera || Revised log levels proposal: "FYI" "WTF" and "OMG" (John Barnette)

Offline

#7 2011-07-22 09:36:20

whoops
Member
Registered: 2009-03-19
Posts: 891

Re: [solved] send keyboard event / key to specific background window?

Nope, not automatizing anything, just keeping an application out of idle mode, but thx!

Offline

Board footer

Powered by FluxBB