from subprocess import run from opencvloc import locateCenterImage import pyautogui as py # 라이브러리 대체 import time run(['calc']) time.sleep(1) ''' x, y = locateCenterImage('5.png') py.click(x,y) x, y = locateCenterImage('mul.png') py.click(x,y) x, y = locateCenterImage('3.png') py.click(x,y) ''' for i in range(1, 10) : x, y = locateCenterImage('add.png') py.click(x,y) x, y = locateCenterImage(str(i)+'.png') py.click(x,y) x, y = locateCenterImage('equal.png') py.click(x,y)
from subprocess import run from opencvloc import locateCenterImage import pyautogui as py # 라이브러리 대체 run(['calc']) for i in range(1, 10): x, y = locateCenterImage("../Image/{}.PNG".format(i)) py.click(x, y) if i < 9: x, y = locateCenterImage("../Image/+.PNG") else: x, y = locateCenterImage("../Image/=.PNG") # time.sleep(1) # x, y = locateCenterImage('../Image/5.PNG') # py.click(x,y) # x, y = locateCenterImage('../Image/5.PNG') # py.click(x,y) # x, y = locateCenterImage('../Image/5.PNG') # py.click(x,y) # x, y = locateCenterImage('../Image/5.PNG') # py.click(x,y)
from subprocess import run from opencvloc import locateCenterImage import pyautogui as py #라이브러리 대체 import time run(['calc']) time.sleep(1) x, y = locateCenterImage('./5.png') py.click(x, y) x, y = locateCenterImage('./x.png') py.click(x, y) x, y = locateCenterImage('./3.png') py.click(x, y) x, y = locateCenterImage('./=.png') py.click(x, y)
from subprocess import run from opencvloc import locateCenterImage import pyautogui as py # 라이브러리 대체 import time run(['calc']) time.sleep(1) x, y = locateCenterImage('5.png') py.click(x, y) x, y = locateCenterImage('plus.png') py.click(x, y) x, y = locateCenterImage('3.png') py.click(x, y) x, y = locateCenterImage('equal.png') py.click(x, y)
from subprocess import run from opencvloc import locateCenterImage import pyautogui as py # 라이브러리 대체 import time run(['calc']) time.sleep(1) # x,y=locateCenterImage('5.png') # py.click(x,y) # x,y=locateCenterImage('plus.png') # py.click(x,y) # x,y=locateCenterImage('3.png') # py.click(x,y) # x,y=locateCenterImage('equal.png') # py.click(x,y) for i in range(1, 10): i = str(i) x, y = locateCenterImage(i + '.png') py.click(x, y) if int(i) != 9: x, y = locateCenterImage('plus.png') py.click(x, y) x, y = locateCenterImage('equal.png') py.click(x, y)
# py.moveTo(lx, ly) def locateCenterImage(img_file): tmp_screen = py.screenshot('./imgs/.tmp_screen.png') cv_screen = cv2.imread("./imgs/.tmp_screen.png") cv_img = cv2.imread(img_file) i_width, i_height, _ = cv_img.shape result = cv2.matchTemplate(cv_screen, cv_img, cv2.TM_CCOEFF_NORMED) y, x = np.unravel_index(result.argmax(), result.shape) return (x + int(i_width / 2), y + int(i_height / 4)) run(["calc"]) time.sleep(1) x, y = locateCenterImage("./imgs/btn_5.png") py.click(x, y) x, y = locateCenterImage("./imgs/btn_mul.png") py.click(x, y) x, y = locateCenterImage("./imgs/btn_3.png") py.click(x, y) x, y = locateCenterImage("./imgs/btn_eql.png") py.click(x, y)