-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathtest.py
74 lines (60 loc) · 1.68 KB
/
test.py
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
"""
examples
- 后台按键需要注册, 需要付费购买注册码, 参考接口说明文件夹
"""
from pydamo import Time, DM, Mouse, Key, vk
dm = DM()
# dm.reg(your_register_code)
# dm.unreg_dm()
ms = Mouse(dm)
kk = Key(dm)
tt = Time()
dm.Beep() # 蜂鸣器
# # ---------------- mouse simulation ---------------
# print(f'Mouse position: {ms.position}') # 当前鼠标位置
#
# tt.sleep(1)
# x, y = (1000, 500)
# ms.move_to(x, y) # 移动鼠标_1
#
# tt.sleep(1)
# x, y = (0, 0)
# ms.position = x, y # 移动鼠标_2
#
# xy = (-100, 0)
# dm.MoveR(*xy)
#
# tt.sleep(1)
# ms.click_right(x, y) # 右键单击(x,y)位置, 按下抬起的间隔为0.5s
#
# tt.sleep(1)
# x, y = (1000, 500)
# ms.click_left(x, y, 2) # 左键单击(x,y)位置, 默认按下抬起的间隔为2s
#
# # ------------ key simulation -----------------------
# tt.sleep(1)
# kk.dp('a') # 按下a键
# tt.sleep(1)
# kk.dp(vk.enter, 1) # 测试enter键
#
# # 全选操作
# tt.sleep(1)
# kk.down(vk.ctrl)
# kk.down('a')
# kk.up(vk.ctrl)
# kk.up('a')
# 像素颜色捕捉
def conv_to_rgb(color):
RGB_str = [color[:2], color[2:-2], color[-2:]]
RGB = [int(i, 16) for i in RGB_str]
return RGB
tt.__init__()
while tt.during(10): # 10s内捕捉鼠标当前位置的颜色
tt.sleep(0.1)
if tt.get_key_state(vk.mouse_right) or tt.is_pressed('alt + x'):
print('--- stopped!')
break # 按下鼠标右键, 或者`alt + x`, 则退出循环
# tt.stop_alt('s') # 按下`alt + s`则停止进程
x, y = ms.position
color = dm.GetColor(x, y)
print(tt.now(1), color, '鼠标位置颜色RGB值:', conv_to_rgb(color))