KianBrose / Image-Recognition-Botting-Tutorial

Hello! This is the code I use in the https://www.youtube.com/watch?v=YRAIUA-Oc1Y video
222 stars 110 forks source link

Outer for loop need to break in aimboot.py #2

Closed UcanYusuf closed 3 years ago

UcanYusuf commented 4 years ago

There are 2 for loops, so we need to break both of them. When we don't use the flag to break the outer for loop, the "q" won't work because the program is still in the for loop. Also, if we didn't break the outer for loop, the mouse click works every 5 pixels even if the conditions are not correct. Thanks for the project.

from pyautogui import *
import pyautogui
import time
import keyboard
import random
import win32api, win32con
import cv2
import numpy as np

time.sleep(2)

def click(x,y):
    win32api.SetCursorPos((x, y))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)

while keyboard.is_pressed('q') == False:
    flag = 0
    pic = pyautogui.screenshot(region=(584, 422, 751, 526))

    width, height = pic.size

    for x in range(0, width, 5):
        for y in range(0, height, 5):

            r, g, b = pic.getpixel((x, y))

            if b == 195 and r == 255 and g == 219:
                flag = 1
                click(x+584, y+422)
                time.sleep(0.05)
                break

        if flag == 1:
            break
thatblocky commented 3 years ago

yea

KianBrose commented 3 years ago

That is correct, is it alright if I update the current aimbooster code to what you have written?

KianBrose commented 3 years ago

Implemented