-
Notifications
You must be signed in to change notification settings - Fork 2
/
DontouchWhite.py
69 lines (60 loc) · 1.65 KB
/
DontouchWhite.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
#!/usr/local/bin/python3.7
import cv2
import numpy as np
from mss import mss
from collections import Counter
from pynput.mouse import Button, Controller
import time
import signal
Y_choice2 = "a"
def INPUT_delay():
class InputTimeoutError(Exception):
pass
def interrupted(signum, frame):
raise InputTimeoutError
signal.signal(signal.SIGALRM, interrupted)
signal.alarm(3)
try:
BB = input('请在1秒内输入你的名字:')
signal.alarm(0) # 读到输入的话重置信号
except InputTimeoutError:
BB = 'A'
return BB
mouse = Controller()
print('The current pointer position is {0}'.format(
mouse.position))
cords = {'top':800 , 'left': 1935, 'width': 420, 'height': 60 }
A =time.time()
while True:
with mss() as sct :
img = np.array(sct.grab(cords)) #sct.grab(cords/monitor)
#img[img==0]=255
img = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY)
#resize to reduce cacl
Ra = 6
# strat
Signal = "Run"
for i in range(int(60/Ra)-4):
i = i*Ra
for ii in range(int(420/Ra)-4):
ii = ii*Ra
if np.sum(img[i,ii])==0:
#img[i:i+4,ii:ii+4] = 255
#print(i,ii)
mouse.position = (1935+ii+20, 800+i+60)
mouse.press(Button.left)
mouse.release(Button.left)
#time.sleep(0.01)
Signal = "Break"
#break
if Signal == "Break":
break
# find the click center
'''
cv2.imshow('image',img)
cv2.moveWindow("image",2800,0)
if cv2.waitKey(1) & 0xFF == ord('q'):
cv2.destroyAllWindows()
break
cv2.destroyAllWindows()
'''