Re: [Vala] Getting/sending sequence of keyboard keys to/from active application



Thank you very much for the information.

On Wed, Sep 16, 2009 at 11:23 AM, Jan Hudec <bulb ucw cz> wrote:

On Wed, Sep 16, 2009 at 10:29:02 +0300, Arkadi Viner wrote:
Hello.
I want to write a program which should record pressed sequences of keys
and
if it receives some shortcut key it will
send delete key to erase wrong typed content, then it will convert from
one
language characters to an another (according to some translation map) and
then send them again to the active application.
It will help people who forgets to switch typing language when they
type...
Maybe some one knows what I should look for? How to hook to an active
application event listener or some how communicate
directly with the X server?

Both XCB and X11 libraries have bindings for vala, but I don't think either
of them is complete. See xcb.vapi and x11.vapi respectively. It might be
even
possible to use gdk (gdk-x11 is bound) for the even handling itself, but
you
will still need to find the windows with x11 (gdk-x11-2.0 depends on x11)
and
it's many extra dependencies if you didn't need your own gui.

For the event handling itself, I believe X allows you to listen to events
on
any window on the display, independently of whether you created it, so if
you
find the window, you can simply register the events.

Just be warned, that X sends keyboard events to the window under mouse and
modern gui libraries go to some length to get the events where they really
want them. It used to make life easier at times of athena widgets (which
simply didn't bother and used that semantics), but now it makes it harder
if
one wants to keep separate keyboard focus.

--
                                                Jan 'Bulb' Hudec <
bulb ucw cz>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]