]> git.lyx.org Git - features.git/blob - development/keystest/test.py
Next patch from John McCabe-Dansted.
[features.git] / development / keystest / test.py
1 #!/usr/bin/env python
2 #This script generated hundreds of random keypresses per second,
3 #  and sends them to the lyx window
4 #It requires xvkbd and wmctrl
5 #It generates a log of the KEYCODES it sends as development/keystest/out/KEYCODES
6
7 import random
8 import os 
9
10 keycode=["\[Left]",'\[Right]','\[Down]','\[Up]','\[BackSpace]','\[Delete]','\[Escape]']
11 keycode[:0]=keycode
12 keycode[:0]=keycode
13
14 keycode[:0]=['\\']
15
16 for k in range(97, 123):
17   keycode[:0]=chr(k)
18
19 for k in range(97, 123):
20   keycode[:0]=["\A"+chr(k)]
21
22 for k in range(97, 123):
23   keycode[:0]=["\A"+chr(k)]
24
25 for k in range(97, 123):
26   keycode[:0]=["\C"+chr(k)]
27
28
29 print (keycode[1])
30 print(keycode)
31 print (random.randint(1,len(keycode)))
32 for k in range(97, 123):
33   print (keycode[random.randint(1,len(keycode))-1])
34
35 #Start a new file. We could also open a random Help file.
36 #os.system("wmctrl -R LyX && xvkbd -xsendevent -text '\Afn';sleep 1")
37 keystr="'\Afn'"
38 os.system("wmctrl -R LyX && xvkbd -xsendevent -text '"+keystr+"';sleep 1")
39 os.system("echo '"+keystr+"'")
40
41 while True:
42   keystr=""
43   for k in range(1,80):
44         keystr=keystr+keycode[random.randint(1,len(keycode))-1]
45   #output keystr before using, to make sure it is output before we are killed
46   os.system("echo '"+keystr+"'")
47   os.system("wmctrl -R LyX && xvkbd -xsendevent -text '"+keystr+"';sleep 1")