-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhotkey.py
More file actions
109 lines (44 loc) · 2.05 KB
/
hotkey.py
File metadata and controls
109 lines (44 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import pyautogui
pyautogui.hotkey('control','h')
pyautogui.typewrite('chrome\n',)
'''
https://automatetheboringstuff.com/chapter18/
pyautogui.hotkey('ctrl', 'c')
pyautogui.hotkey('ctrl', 'alt', 'shift', 's')
moveTo(x, y). Moves the mouse cursor to the given x and y coordinates.
moveRel(xOffset, yOffset). Moves the mouse cursor relative to its current position.
dragTo(x, y). Moves the mouse cursor while the left button is held down.
dragRel(xOffset, yOffset). Moves the mouse cursor relative to its current position while the left button is held down.
click(x, y, button). Simulates a click (left button by default).
rightClick(). Simulates a right-button click.
middleClick(). Simulates a middle-button click.
doubleClick(). Simulates a double left-button click.
mouseDown(x, y, button). Simulates pressing down the given button at the position x, y.
mouseUp(x, y, button). Simulates releasing the given button at the position x, y.
scroll(units). Simulates the scroll wheel. A positive argument scrolls up; a negative argument scrolls down.
typewrite(message). Types the characters in the given message string.
typewrite([key1, key2, key3]). Types the given keyboard key strings.
press(key). Presses the given keyboard key string.
keyDown(key). Simulates pressing down the given keyboard key.
keyUp(key). Simulates releasing the given keyboard key.
hotkey([key1, key2, key3]). Simulates pressing the given keyboard key strings down in order and then releasing them in reverse order.
screenshot(). Returns a screenshot as an Image object. (See Chapter 17 for information on Image objects.)
from system_hotkey.system_hotkey import SystemHotkey
hk = SystemHotkey(use_xlib=False)
hk.unregister(('control', 'a',), callback=lambda e:print('hi'))
while 1:
pass
Supported modifiers include:
control
shift
super (windows key)
alt
'''
'''
# 2019.12.30.02.16.26.510
from system_hotkey.system_hotkey import SystemHotkey
hk = SystemHotkey(use_xlib=False)
hk.register(('control', 'a',), callback=lambda e:print('hi'))
while 1:
pass
'''