-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathFindClick.py
More file actions
80 lines (54 loc) · 1.94 KB
/
FindClick.py
File metadata and controls
80 lines (54 loc) · 1.94 KB
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
75
76
77
78
79
# -*- coding: utf-8 -*-
"""
Created on Tue Feb.1 09:12:41 2022
@author: gw.kayak
"""
import os
import sys
from PIL import ImageGrab
import pyautogui
import time
# yolox label, top, left, bottom, right
class FindClick(object):
#有默认值放后
def __init__(self,Use_AI = False):
self.Use_AI = Use_AI
def mouse_press_without_ai(
self,
match_pic_path,
click='doubleclick',
click_times = 1,
confidence = 0.6,
mousedown_last_time = 0.025,
):
if click == 'click':
try:
img_location = pyautogui.locateCenterOnScreen(match_pic_path,confidence=confidence)
for i in range(click_times):
pyautogui.click(x=img_location[0], y=img_location[1])
except:
print('Click Fail')
elif click == 'doubleclick':
try:
img_location = pyautogui.locateCenterOnScreen(match_pic_path,confidence=confidence)
for i in range(click_times):
pyautogui.doubleClick(x=img_location[0], y=img_location[1])
except:
print('Doubleclick Fail')
elif mousedown_last_time != 0.025:
try:
pyautogui. mouseDown()
time.sleep(mousedown_last_time)
pyautogui.mouseUp()
except:
print('Click Fail')
else:
print('args error')
def press_keyboard(self,keyboard_input_list):
pyautogui.press(keyboard_input_list)
def action(self,match_pic_path=None):
if self.Use_AI == False:
self.mouse_press_without_ai(match_pic_path)
else:
import yolox.predict
yolox.predict.dectect()