|
10 | 10 | # check if a ctrl is pressed |
11 | 11 | print(keyboard.is_pressed('ctrl')) |
12 | 12 |
|
13 | | -# press space |
| 13 | +# pressand releasespace |
14 | 14 | keyboard.send("space") |
15 | 15 |
|
| 16 | +# multi-key, windows+d as example shows the desktop in Windows machines |
| 17 | +keyboard.send("windows+d") |
| 18 | + |
| 19 | +# send ALT+F4 in the same time, and then send space, |
| 20 | +# (be carful, this will close any current open window) |
| 21 | +keyboard.send("alt+F4, space") |
| 22 | + |
| 23 | +# press CTRL button |
| 24 | +keyboard.press("ctrl") |
| 25 | +# release the CTRL button |
| 26 | +keyboard.release("ctrl") |
| 27 | + |
16 | 28 | # sends artificial keyboard events to the OS |
17 | 29 | # simulating the typing of a given text |
18 | 30 | # setting 0.1 seconds to wait between keypresses to look fancy |
|
22 | 34 | events=keyboard.record('esc') |
23 | 35 | # play these events |
24 | 36 | keyboard.play(events) |
| 37 | +# print all typed strings in the events |
| 38 | +print(list(keyboard.get_typed_strings(events))) |
| 39 | + |
| 40 | +# log all pressed keys |
| 41 | +keyboard.on_release(lambdae:print(e.name)) |
25 | 42 |
|
26 | 43 | # remove all keyboard hooks in use |
27 | 44 | keyboard.unhook_all() |
|