stumpwm-devel
[Top][All Lists]
Advanced

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

Re: [STUMP] Sending keypress events to an application


From: Lionel Flandrin
Subject: Re: [STUMP] Sending keypress events to an application
Date: Sat, 12 Mar 2011 12:26:07 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

On Sat, Mar 12, 2011 at 12:23:22PM +0100, Sven Hartrumpf wrote:
> Hi all.
> 
> I asked:
> >> I am running stumpwm under sbcl 1.0.43 and clx 0.7.4.
> >> Does this version contain xtest support?
> 
> Yes!
> I have tried the following example in .stumpwmrc:
> 
> (defcommand save-acroread-to-text ()
>   ()
>   "Save the text from the currently focused acrobat reader window"
>   (xtest:fake-key-event *display* 64 t)    ; alt
>   (xtest:fake-key-event *display* 41 t)    ; f
>   (xtest:fake-key-event *display* 41 nil)
>   (xtest:fake-key-event *display* 64 nil)
>   (xtest:fake-key-event *display* 55 t)    ; v
>   (xtest:fake-key-event *display* 55 nil)
>   (xtest:fake-key-event *display* 36 t)    ; enter
>   (xtest:fake-key-event *display* 36 nil)
>   (sleep 5)
>   (xtest:fake-key-event *display* 37 t)    ; ctrl
>   (xtest:fake-key-event *display* 24 t)    ; q
>   (xtest:fake-key-event *display* 24 nil)
>   (xtest:fake-key-event *display* 37 nil))
> 
> (define-key *top-map* (kbd "F6") "save-acroread-to-text")
> 
> This works almost as expected.
> But a timing problem remains:
> I added the (sleep 5) to give acoread time for saving the text.
> But obviously the sleep happens before all the key events
> are sent and hence the final Ctrl-q is sometimes arriving
> at the right window, sometimes not.
> 
> How can I improve this?
> 
> Sven

You need to flush the events, if memory serves this is done properly
by calling (clx:display-finish-output *display*) when you want to
flush all the events.

IIRC stumpwm adds one of those after each command is executed, so you
don't need to add one at the end, but if you want to flush the buffer
in the middle as is your case here you have to call it explicitely.

-- 
Lionel Flandrin

Attachment: pgphWXXNM9M46.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]