forked from pyinput/python-uinput
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmouse.py
More file actions
executable file
·28 lines (22 loc) · 730 Bytes
/
mouse.py
File metadata and controls
executable file
·28 lines (22 loc) · 730 Bytes
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
import time
import uinput
def main():
events = (
uinput.REL_X,
uinput.REL_Y,
uinput.BTN_LEFT,
uinput.BTN_RIGHT,
)
with uinput.Device(events) as device:
for i in range(20):
# syn=False to emit an "atomic" (5, 5) event.
device.emit(uinput.REL_X, 5, syn=False)
device.emit(uinput.REL_Y, 5)
# Just for demonstration purposes: shows the motion. In real
# application, this is of course unnecessary.
time.sleep(0.01)
# Emit left mouse click
device.emit(uinput.BTN_LEFT, 1) # Button pressed
device.emit(uinput.BTN_LEFT, 0) # Button released
if __name__ == "__main__":
main()