正文
#coding=utf-8 import time import autopy #quick move autopy.mouse.move(1,1) #smooth move #autopy.mouse.smooth_move(1370,120)
新增AI编程课程,引领技术教育新趋势
正文
#coding=utf-8 import time import autopy #quick move autopy.mouse.move(1,1) #smooth move #autopy.mouse.smooth_move(1370,120)
会发现鼠标瞬间移动到坐标(1,1)的位置,我的电脑是1920*1080的,最右下角的坐标就是(1920,1080)。
将move换成smooth_move,会发现鼠标慢慢地移动到指定坐标
官方文档的解释:
autopy.mouse.move(x: float, y: float)
Moves the mouse to the given (x, y) coordinate.
Exceptions:
ValueError is thrown if the point is out of index.
autopy.mouse.smooth_move(x: float, y: float)
Smoothly moves the mouse to the given (x, y) coordinate in a straight line.
Exceptions:
ValueError is thrown if the point is out of index.
坐标超过分辨率会报异常
运行代码,发现当前位置产生了点击操作
#coding=utf-8 import autopy autopy.mouse.click() # 单击
下面时一些常见的键值码和键的对应:
字母和数字键 数字小键盘的键 功能键 其它键
键 键码 键 键码 键 键码 键 键码
A 65 0 96 F1 112 Backspace 8
B 66 1 97 F2 113 Tab 9
C 67 2 98 F3 114 Clear 12
D 68 3 99 F4 115 Enter 13
E 69 4 100 F5 116 Shift 16
F 70 5 101 F6 117 Control 17
G 71 6 102 F7 118 Alt 18
H 72 7 103 F8 119 Caps Lock 20
I 73 8 104 F9 120 Esc 27
J 74 9 105 F10 121 Spacebar 32
K 75 * 106 F11 122 Page Up 33
L 76 + 107 F12 123 Page Down 34
M 77 Enter 108 End 35
N 78 - 109 Home 36
O 79 . 110 Left Arrow 37
P 80 / 111 Up Arrow 38
Q 81 Right Arrow 39
R 82 Down Arrow 40
S 83 Insert 45
T 84 Delete 46
U 85 Help 47
V 86 Num Lock 144
W 87
X 88
Y 89
Z 90
0 48
1 49
2 50
3 51
4 52
5 53
6 54
7 55
8 56
9 57
复制代码,运行,这里需要win32api包
调用win32api的keybd_e