def sort(): # Sort print('Sort') for i in range(3): s1 = imagesearch(impath + "\\Sort\\S" + str(i + 1) + "A.png") dest = imagesearch(impath + "Sort\\D" + str(i + 1) + ".png") if dest[0] != -1: print("dest position : ", dest[0], dest[1]) pyautogui.moveTo(s1[0], s1[1]) pyautogui.dragTo(dest[0], dest[1], 1) else: print("dest not found") s2 = imagesearch(impath + "Sort\\S" + str(i + 1) + "B.png") if dest[0] != -1: pyautogui.moveTo(s2[0], s2[1]) pyautogui.dragTo(dest[0], dest[1], 1) if s1[0] != -1: print("s1 position : ", s1[0], s1[1]) else: print("s1 not found") if s2[0] != -1: print("s2 position : ", s2[0], s2[1]) else: print("s2 not found")
def isChampSelect(): #şampiyon seçim ekranına girdi mi slcscreen = imagesearch(selectscreenimg) icon = imagesearch(iconimg) if not slcscreen[0] == -1 or not icon[0] == -1: return True else: return False
def isCancelled(): #oyun iptal oldu mu kabul = imagesearch(kabulimg) iptal1 = imagesearch(iptal1img) iptal2 = imagesearch(iptal2img) if kabul[0] == -1 and (iptal1[0] != -1 or iptal2[0] != -1): return True else: return False
def imageSearchAndClick(image, precision=0.8) -> bool: pos = imagesearch(image, precision) if pos[0] != -1: pyautogui.moveTo(pos[0], pos[1], 0.05) pyautogui.click() return True return False
from python_imagesearch.imagesearch import * import pyautogui as pag #변수초기화 found_img = 0 #프로그램시작 print("Start seeking..") process_list = { 'obj1': './obj1.png', 'obj2': './obj2.png', 'obj3': './obj3.png', 'obj4': './obj4.png' } for key, value in process_list.items(): found_img = 0 while found_img == 0: print("searching {}..".format(key)) find_img = imagesearch(process_list.get(key)) if find_img[0] != -1: pag.moveTo(find_img[0] + 20, find_img[1] + 20) pag.click() found_img = -1 #반복문 탈출 print("{} has been found!".format(key))
import pyautogui from python_imagesearch.imagesearch import * from pynput.mouse import Button, Controller from pynput.keyboard import Key, Controller import pydirectinput import threading import time import keyboard import random import win32api, win32con while 1: mouse = Controller() keyboard = Controller() pos = imagesearch("press_f.png") if pos[0] != -1: print("position : ", pos[0], pos[1]) press('f') press('f') press('f') pos = imagesearcharea("nv.png", 0, 0, 1400, 900) if pos[0] != -1: pydirectinput.moveTo(pos[0], pos[1]) pyautogui.scroll(-10) pyautogui.tripleClick() press('e') #pydirectinput.moveTo(None, 30) #else: #press('w') #temos que separar isso daqui em outra execucao
def pixColor(x, y): return pyautogui.pixel(x, y) path = "C:\\Users\\jacob\\PycharmProjects\\Among USSR\\Images\\TASKS\\" print('Welcome. Current automated tasks:') for task in os.listdir(path): print(task.split('.')[0]) print('\nNow looking for tasks...') printCursor() while (True): if imagesearch(path + "BoardingPass.png")[0] != -1: boardingPass() elif imagesearch(path + "Thrash.png")[0] != -1: thrash() elif imagesearch(path + "IDcode.png")[0] != -1: idCode() elif imagesearch(path + "Shields.png")[0] != -1: shields() elif imagesearch(path + "Shields2.png")[0] != -1: shields() elif imagesearch(path + "Slider.png")[0] != -1: powerSlide() elif imagesearch(path + "PowerClick.png")[0] != -1: powerClick() elif imagesearch(path + "Wires.png")[0] != -1: wires()
from python_imagesearch.imagesearch import * # Search for the github logo on the whole screen # note that the search only works on your primary screen. # This is intended to be used as examples to be copy pasted, do not run the whole file at once pos = imagesearch("./start.png") if pos[0] != -1: print("position : ", pos[0], pos[1]) pyautogui.moveTo(pos[0], pos[1]) else: print("image not found") # search for the github logo until found : pos = imagesearch_loop("./start.png", 0.5) print("image found ", pos[0], pos[1]) # search for the logo on the 0,0,800,600 region # (a rectangle starting from the top left going 800 pixels to the right and down 600 pixels) pos = imagesearcharea("./start.png", 0, 0, 800, 600) if pos[0] != -1: print("position : ", pos[0], pos[1]) pyautogui.moveTo(pos[0], pos[1]) else: print("image not found") # the im parameter is useful if you plan on looking for several different images without the need for recapturing the screen