Mailingliste - Einträge 2006

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

[qftestJUI] Replay configurable key-events

  • Subject: [qftestJUI] Replay configurable key-events
  • From: "Michaelis, Mark" <mark.michaelis@?.com>
  • Date: Tue, 21 Mar 2006 09:03:35 +0100

I found (one possible) solution to replay configurable key-events. E. g. I
want to store the shortcut to save a document in a properties file, like:
save-action=ctrl s
The trick is to use javax.swing.KeyStroke to parse these properties and to
1. a Jyhton Module which does the parsing in an object KeyEvent
2. a Server-Script which creates the object KeyEvent and runs it
3. a Hook-Procedure which is called from the Jython Module to actually send
the KEY_PTR event
I attached the Jython Module I use. The Server Script is embedded in a
procedure I called keyboard_event(kbd_event, component) which looks as
import keyboard
if ${qftestJUI:batch}==false:
kbd_event = rc.lookup("kbd_event")
component = rc.lookup("component")
event = keyboard.KeyboardEvent(kbd_event)
event.replay(rc, component)
Mind that you have to use a Server Script here and not a SUT Script. If you
will use a SUT Script and your keystroke opens a modal dialog your script
will just hang... waiting for the modal dialog as it runs on the AWT
EventQueue (thanks to Gregor for this tip). As kbd_event you may use any
format supported by javax.swing.KeyStroke. In addition you can also add
sequences of keystrokes like: ctrl S,ctrl U which will be replayed in a
The hook procedure is currently named "common.qf.key_press" (see and has the variables keyCode, keyChar and keyModifier. The
procedure only includes a KEY_PTR event. That's all.
One additional hint:
In the Server Skript above I added a reload-statement if qftest is not
running in batch-mode. This helps me a lot during development where the
python-modules often change.
Now I just hope that the attachments works.
Mark Michaelis
Software Engineer Quality Assurance

fon      +49 .40 .32 55 87 .545
fax      +49 .40 .32 55 87 .999
email    mark.michaelis@?.com  

CoreMedia AG
Ludwig-Erhard-Str. 18
20459 Hamburg, Germany

Any Content, Anywhere, in a Trusted Universe:
CoreMedia CMS and CoreMedia DRM

Description: Binary data

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Videos Downloads Dokumentation Kaufen Gratis Testen