FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythoncode-tutorials/general/mouse-controller/control_mouse.py at master · hsg/pythoncode-tutorials · GitHub
hsg
/
pythoncode-tutorials
Public
forked from
x4nth055/pythoncode-tutorials
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythoncode-tutorials
/
general
/
mouse-controller
/
control_mouse.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (34 loc) · 1004 Bytes
Breadcrumbs
pythoncode-tutorials
/
general
/
mouse-controller
/
control_mouse.py
Copy path
File metadata and controls
50 lines (34 loc) · 1004 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
mouse
# left click
mouse
.
click
(
'left'
)
# right click
mouse
.
click
(
'right'
)
# middle click
mouse
.
click
(
'middle'
)
# get the position of mouse
print
(
mouse
.
get_position
())
# In [12]: mouse.get_position()
# Out[12]: (714, 488)
# presses but doesn't release
mouse
.
hold
(
'left'
)
# mouse.press('left')
# drag from (0, 0) to (100, 100) relatively with a duration of 0.1s
mouse
.
drag
(
0
,
0
,
100
,
100
,
absolute
=
False
,
duration
=
0.1
)
# whether a button is clicked
print
(
mouse
.
is_pressed
(
'right'
))
# move 100 right & 100 down
mouse
.
move
(
100
,
100
,
absolute
=
False
,
duration
=
0.2
)
# make a listener when left button is clicked
mouse
.
on_click
(
lambda
:
print
(
"Left Button clicked."
))
# make a listener when right button is clicked
mouse
.
on_right_click
(
lambda
:
print
(
"Right Button clicked."
))
# remove the listeners when you want
mouse
.
unhook_all
()
# scroll down
mouse
.
wheel
(
-
1
)
# scroll up
mouse
.
wheel
(
1
)
# record until you click right
events
=
mouse
.
record
()
# replay these events
mouse
.
play
(
events
[:
-
1
])
Back
|
FazBrowse Home
|
New Git URL