├── im2.png ├── img.PNG ├── README.md ├── check3.1.py └── check3.2.py /im2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyrixn/check/HEAD/im2.png -------------------------------------------------------------------------------- /img.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyrixn/check/HEAD/img.PNG -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | - **仅支持64位系统** 2 | - 优先试check3.2,不能正常运行再check3.1 3 | - 虚拟机上运行然后把虚拟机最小化能不能正常工作没试过,但是应该要外接一个鼠标让虚拟机独立控制 4 | - 用这个仓库里的的图测试 5 | - 目前只实现windows,安卓模拟器还没写完,进去输入1回车就行了 6 | - 会有提示音但是设置了3秒以内点,保证不漏点而已,~~大家还是要好好学习的!~~ 7 | - 资源占用挺高的,还没有解决 8 | - 控制开启和关闭的鼠标手势在搞了在搞了 9 | 10 | 11 | **本项目仅供学习交流使用,勿作他用** 12 | -------------------------------------------------------------------------------- /check3.1.py: -------------------------------------------------------------------------------- 1 | #coding=utf-8 2 | 3 | import random 4 | import time 5 | import numpy as np 6 | import cv2 7 | import pyautogui as pag 8 | from PIL import ImageGrab 9 | from pynput.mouse import Button,Controller 10 | 11 | cnt=int(0) 12 | rt=[[0]*2]*2 13 | kd=[0]*2 14 | pre =[0]*4 15 | now =[0]*4 16 | lower_blue=[0]*2 17 | upper_blue=[0]*2 18 | mouse =Controller() 19 | WIDE,HEIGHT=pag.size() 20 | 21 | BOX = (0, 0, WIDE, HEIGHT) 22 | kd[0]=True;kd[1]=False 23 | rt[0]=[4.3,4.6];rt[1]=[5.05,5.5] 24 | 25 | #HSV: 色相0-180度,饱和度0-255对应0-180,亮度0-255对应0-180 别搞错了 26 | #winddows 27 | lower_blue[1] = np.array([99,123,255]) 28 | upper_blue[1] = np.array([105,205,255]) 29 | #原:145 #现:205 30 | #android:197,79,96 31 | #629 139 433 97 198 45 143 32 342 78 459 104 646 143 940 207 32 | lower_blue[0] = np.array([98,200,237]) 33 | upper_blue[0] = np.array([100,202,245]) 34 | 35 | orgimg = np.array(ImageGrab.grab(bbox=BOX)) 36 | 37 | ver=int(input("Mod[0]And, [1]windows: ")) 38 | 39 | def change(): #B,R通道互換 40 | global orgimg 41 | b, g, r = cv2.split(orgimg) 42 | orgimg = cv2.merge([r, g, b]) 43 | 44 | def judg(xx,yy,ww,hh): 45 | global ver 46 | if hh !=0 and ww/hh >rt[ver][0] and ww/hh =9020): 47 | return True 48 | else: 49 | return False 50 | 51 | def delay(): 52 | tm =random.random()*3.7+0.3 53 | print("delay: "+str(tm)+"s") 54 | time.sleep(tm) 55 | 56 | change() 57 | while True: 58 | orgimg = np.array(ImageGrab.grab(bbox=BOX)) 59 | change() 60 | # orgimg =cv2.imread("img1.jpg") 61 | #图像是否可拉伸 62 | # cv2.namedWindow("img", cv2.WINDOW_NORMAL) 63 | 64 | img = cv2.cvtColor(orgimg, cv2.COLOR_BGR2HSV) 65 | mask = cv2.inRange(img, lower_blue[ver], upper_blue[ver]) 66 | mask = cv2.medianBlur(mask,5) 67 | ret,btton=cv2.threshold(mask,254,255,0) 68 | contours, hiera=cv2.findContours(btton, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) 69 | 70 | x=y=w=h=0 71 | flag =False 72 | for tmp in contours: 73 | x, y, w, h = cv2.boundingRect(tmp) 74 | if judg(x,y,w,h): 75 | # print(str(x), str(y), str(w), str(h)) 76 | flag=True;break 77 | # x, y, w, h = cv2.boundingRect(btton) 78 | # print("____________________") 79 | if flag: 80 | now[0]=x;now[1]=y;now[2]=w;now[3]=h 81 | if now != pre: 82 | 83 | delay() 84 | mouse.position =(int(x+w/2),int(y+h/2)) 85 | print(str(x+w/2), str(y+h/2), str(w), str(h)) 86 | mouse.click(Button.left,3) 87 | print('\a') 88 | print("CHECK!") 89 | pre[0]=now[0];pre[1]=now[1];pre[2]=now[2];pre[3]=now[3] 90 | cnt=cnt+1 91 | # print(cnt) 92 | time.sleep(0.2) 93 | 94 | # cv2.rectangle(orgimg, (x, y), (x + w, y + h), (0, 0, 255), 2) 95 | 96 | # cv2.imshow("img", cv2.cvtColor(btton, cv2.COLOR_BGR2RGB)) 97 | if cv2.waitKey(25) & 0xFF == ord("q"): 98 | cv2.destroyAllWindows() 99 | break 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /check3.2.py: -------------------------------------------------------------------------------- 1 | #coding=utf-8 2 | 3 | import random 4 | from time import sleep 5 | import numpy as np 6 | from cv2 import split,merge,cvtColor,inRange,medianBlur,threshold,findContours,boundingRect,waitKey,destroyAllWindows,COLOR_BGR2HSV,RETR_EXTERNAL,CHAIN_APPROX_SIMPLE 7 | from pyautogui import moveTo,doubleClick,size 8 | from PIL import ImageGrab 9 | 10 | cnt=int(0) 11 | rt=[[0]*2]*2 12 | kd=[0]*2 13 | pre =[0]*4 14 | now =[0]*4 15 | lower_blue=[0]*2 16 | upper_blue=[0]*2 17 | WIDE,HEIGHT=size() 18 | mark=False 19 | 20 | cnt =int(1) 21 | BOX = (0, 0, WIDE, HEIGHT) 22 | kd[0]=True;kd[1]=False 23 | rt[0]=[4.3,4.6];rt[1]=[5.05,5.5] 24 | 25 | #HSV: 色相0-180度,饱和度0-255对应0-180,亮度0-255对应0-180 别搞错了 26 | #winddows 27 | lower_blue[1] = np.array([99,123,255]) 28 | upper_blue[1] = np.array([105,205,255]) 29 | #原:145 #现:205 30 | #android:197,79,96 31 | #629 139 433 97 198 45 143 32 342 78 459 104 646 143 940 207 32 | lower_blue[0] = np.array([98,200,237]) 33 | upper_blue[0] = np.array([100,202,245]) 34 | 35 | orgimg = np.array(ImageGrab.grab(bbox=BOX)) 36 | 37 | ver=int(input("Mod[0]And, [1]windows: ")) 38 | if ver== 3: 39 | mark=True 40 | ver=1 41 | 42 | def change(): #B,R通道互換 43 | global orgimg 44 | b, g, r = split(orgimg) 45 | orgimg = merge([r, g, b]) 46 | 47 | def judg(xx,yy,ww,hh): 48 | global ver 49 | if hh !=0 and ww/hh >rt[ver][0] and ww/hh =9020): 50 | return True 51 | else: 52 | return False 53 | def delay(): 54 | if mark: 55 | sleep(0.2) 56 | else: 57 | tm =random.random()*2.7+0.3 58 | print("delay: "+str(tm)+"s") 59 | sleep(tm) 60 | 61 | change() 62 | print("resolution: "+str(WIDE)+"*"+str(HEIGHT)) 63 | while True: 64 | sleep(0.2) 65 | orgimg = np.array(ImageGrab.grab(bbox=BOX)) 66 | change() 67 | # orgimg =cv2.imread("img1.jpg") 68 | #图像是否可拉伸 69 | # cv2.namedWindow("img", cv2.WINDOW_NORMAL) 70 | 71 | img = cvtColor(orgimg, COLOR_BGR2HSV) 72 | mask = inRange(img, lower_blue[ver], upper_blue[ver]) 73 | mask = medianBlur(mask,5) 74 | ret,btton=threshold(mask,254,255,0) 75 | contours, hiera=findContours(btton, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE) 76 | 77 | x=y=w=h=0 78 | flag =False 79 | for tmp in contours: 80 | x, y, w, h = boundingRect(tmp) 81 | if judg(x,y,w,h): 82 | flag=True;break 83 | # x, y, w, h = cv2.boundingRect(btton) 84 | if flag: 85 | now[0]=x;now[1]=y;now[2]=w;now[3]=h 86 | if now != pre: 87 | print('\a') 88 | delay() 89 | moveTo(int(x+w/2),int(y+h/2)) 90 | doubleClick(button='left') 91 | 92 | print(str(x+w/2), str(y+h/2), str(w), str(h)) 93 | print("CHECK! ---------- 第"+str(++cnt)+"次") 94 | 95 | pre[0]=now[0];pre[1]=now[1];pre[2]=now[2];pre[3]=now[3] 96 | cnt=cnt+1 97 | sleep(0.2) 98 | 99 | # cv2.rectangle(orgimg, (x, y), (x + w, y + h), (0, 0, 255), 2) 100 | 101 | # cv2.imshow("img", cv2.cvtColor(btton, cv2.COLOR_BGR2RGB)) 102 | if waitKey(25) & 0xFF == ord("q"): 103 | destroyAllWindows() 104 | break 105 | 106 | 107 | 108 | --------------------------------------------------------------------------------