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: Sven Hartrumpf
Subject: Re: [STUMP] Sending keypress events to an application
Date: Sat, 12 Mar 2011 12:23:22 +0100 (CET)

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



reply via email to

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