├── README.txt ├── aimbooster.py ├── pianotiles.py ├── regionscreenshotsaver.py └── stickman.py /README.txt: -------------------------------------------------------------------------------- 1 | # IMPORTANT NOTE 2 | 3 | If you came here from the YouTube video, keep in mind that using .locateOnScreen(..) == None does not work on newer versions of Pyautogui because the devs decided to change the syntax 4 | 5 | 6 | 7 | # Image-Recognition-Botting-Tutorial 8 | Hello! This is the code I use in the https://www.youtube.com/watch?v=YRAIUA-Oc1Y video 9 | 10 | Install these libraries from an administrator terminal (windows): 11 | 12 | pip install pywin32 13 | pip install keyboard 14 | pip install pyautogui 15 | pip install opencv-python 16 | 17 | Here are the libraries to paste at the start of the scripts: 18 | 19 | from pyautogui import * 20 | import pyautogui 21 | import time 22 | import keyboard 23 | import random 24 | import win32api, win32con 25 | 26 | Here is the click function: 27 | 28 | def click(x,y): 29 | win32api.SetCursorPos((x,y)) 30 | win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0) 31 | win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0) 32 | -------------------------------------------------------------------------------- /aimbooster.py: -------------------------------------------------------------------------------- 1 | from pyautogui import * 2 | import pyautogui 3 | import time 4 | import keyboard 5 | import random 6 | import win32api, win32con 7 | 8 | time.sleep(2) 9 | 10 | def click(x,y): 11 | win32api.SetCursorPos((x,y)) 12 | win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0) 13 | win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0) 14 | 15 | #Color of center: (255, 219, 195) 16 | 17 | while keyboard.is_pressed('q') == False: 18 | flag = 0 19 | pic = pyautogui.screenshot(region=(584, 422, 751, 526)) 20 | 21 | width, height = pic.size 22 | 23 | for x in range(0, width, 5): 24 | for y in range(0, height, 5): 25 | 26 | r, g, b = pic.getpixel((x, y)) 27 | 28 | if b == 195 and r == 255 and g == 219: 29 | flag = 1 30 | click(x+584, y+422) 31 | time.sleep(0.05) 32 | break 33 | 34 | if flag == 1: 35 | break 36 | -------------------------------------------------------------------------------- /pianotiles.py: -------------------------------------------------------------------------------- 1 | from pyautogui import * 2 | import pyautogui 3 | import time 4 | import keyboard 5 | import random 6 | import win32api, win32con 7 | 8 | #Tile 1 Position: X: 581 Y: 400 RGB: ( 77, 80, 115) 9 | #Tile 2 Position: X: 682 Y: 400 RGB: ( 0, 0, 0) 10 | #Tile 3 Position: X: 770 Y: 400 RGB: ( 79, 82, 116) 11 | #Tile 4 Position: X: 869 Y: 400 RGB: ( 80, 83, 116) 12 | 13 | def click(x,y): 14 | win32api.SetCursorPos((x,y)) 15 | win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0) 16 | time.sleep(0.1) #This pauses the script for 0.1 seconds 17 | win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0) 18 | 19 | while keyboard.is_pressed('q') == False: 20 | 21 | if pyautogui.pixel(581, 400)[0] == 0: 22 | click(581, 400) 23 | if pyautogui.pixel(682, 400)[0] == 0: 24 | click(682, 400) 25 | if pyautogui.pixel(770, 400)[0] == 0: 26 | click(770, 400) 27 | if pyautogui.pixel(869, 400)[0] == 0: 28 | click(869, 400) 29 | -------------------------------------------------------------------------------- /regionscreenshotsaver.py: -------------------------------------------------------------------------------- 1 | #This script saves the image of the region 660,350,600,400 as savedimage.png in the path "C:\Users\Antec\Desktop\Tutorial\savedimage.png" 2 | 3 | import pyautogui 4 | 5 | im1 = pyautogui.screenshot(region=(660,350,600,400)) 6 | im1.save(r"./savedimage.png") 7 | -------------------------------------------------------------------------------- /stickman.py: -------------------------------------------------------------------------------- 1 | #This script locates the image stickman.png in the region we give it and tell you if it can see it 2 | 3 | from pyautogui import * 4 | import pyautogui 5 | import time 6 | import keyboard 7 | import random 8 | import win32api, win32con 9 | 10 | while 1: 11 | if pyautogui.locateOnScreen('stickman.png', region=(150,175,350,600), grayscale=True, confidence=0.8) != None: 12 | print("I can see it") 13 | time.sleep(0.5) 14 | else: 15 | print("I am unable to see it") 16 | time.sleep(0.5) 17 | --------------------------------------------------------------------------------