-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask.py
More file actions
26 lines (21 loc) · 948 Bytes
/
Task.py
File metadata and controls
26 lines (21 loc) · 948 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
import win32api
import setting as s
import win32con
import ctypes
import time
class Task:
def __init__(self, position: list=[0, 0], operation: bool=False, ):
self.pos = position # 坐标
self.op = operation # 要执行的操作
# op为True代表单击左键,op为False代表单击右键
def Execute(self):
# 进行坐标的换算
touch_pos = (132 + self.pos[0] * (s.SENIOR_PIXEL_GAPX), 148 + self.pos[1] * (s.SENIOR_PIXEL_GAPY))
ctypes.windll.user32.SetCursorPos(int(touch_pos[0]),int(touch_pos[1]))
if self.op == True:
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
else:
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
time.sleep(0.02)