lyx_mirror/development/keystest/test.py
Pavel Sanda 3f3d37ca09 Next patch from John McCabe-Dansted.
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg152211.html

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30148 a592a061-630c-0410-9148-cb99ea01b6c8
2009-06-17 17:56:56 +00:00

48 lines
1.3 KiB
Python
Executable File

#!/usr/bin/env python
#This script generated hundreds of random keypresses per second,
# and sends them to the lyx window
#It requires xvkbd and wmctrl
#It generates a log of the KEYCODES it sends as development/keystest/out/KEYCODES
import random
import os
keycode=["\[Left]",'\[Right]','\[Down]','\[Up]','\[BackSpace]','\[Delete]','\[Escape]']
keycode[:0]=keycode
keycode[:0]=keycode
keycode[:0]=['\\']
for k in range(97, 123):
keycode[:0]=chr(k)
for k in range(97, 123):
keycode[:0]=["\A"+chr(k)]
for k in range(97, 123):
keycode[:0]=["\A"+chr(k)]
for k in range(97, 123):
keycode[:0]=["\C"+chr(k)]
print (keycode[1])
print(keycode)
print (random.randint(1,len(keycode)))
for k in range(97, 123):
print (keycode[random.randint(1,len(keycode))-1])
#Start a new file. We could also open a random Help file.
#os.system("wmctrl -R LyX && xvkbd -xsendevent -text '\Afn';sleep 1")
keystr="'\Afn'"
os.system("wmctrl -R LyX && xvkbd -xsendevent -text '"+keystr+"';sleep 1")
os.system("echo '"+keystr+"'")
while True:
keystr=""
for k in range(1,80):
keystr=keystr+keycode[random.randint(1,len(keycode))-1]
#output keystr before using, to make sure it is output before we are killed
os.system("echo '"+keystr+"'")
os.system("wmctrl -R LyX && xvkbd -xsendevent -text '"+keystr+"';sleep 1")