0

I am trying to make an aimbot for diep. I am trying to locate all enemies on the screen, but with 1 confidence it returns None and with 0.9999 confidence it returns every single position on the screen.

I am using PyCharm, and when I run the code, it returns every location on the screen even though there isn't anything red. Then when I set confidence to 1, it doesn't even return locations that are red.

I have even tried opening the file and seeing if it could find the color. It didn't work, same results.

My Code

# https://pyautogui.readthedocs.io/en/latest/screenshot.html
from pyautogui import locateAllOnScreen, moveTo

while True:
    """
    try:
        coords = list(locateAllOnScreen('enemycolordiep.png'))
    except 'ImageNotFoundException':
        coords = []
    """

    coords = locateAllOnScreen('enemycolordiep.png', confidence=X)
    if coords is None:
        coords = []

    else:
        coords = list(coords)

    print(coords)

    for coord in coords:
        centerCoord = (coord[0] + (coord[2] / 2), coord[1] + (coord[3] / 2))
        print(centerCoord)
        # moveTo(centerCoord[0], centerCoord[1], duration=0)

I expected to get the red locations on the screen, but this is not working. I have pyautogui, pyobjc-core, pyobjc-framework-quartz, Pillow, opencv-python, and a bunch of other stuff that those packages were dependent on. I am using MacOS Mojave. Thanks for the help!

Nv7
  • 406
  • 6
  • 20
  • Using pillow: check my answer [here](https://stackoverflow.com/a/56636259/8928024) to see how you test for color value of a particular pixel. BTW.. update your question to include the pillow code you use. Can be posted as second scritp in your question termed "alternative" or something. – ZF007 Jun 20 '19 at 00:00
  • How will RGB color matching help with image location? – Nv7 Jun 20 '19 at 13:44
  • ... you stated "locations that are red" are more or less enemies. In WoW its a circled shield in color yellow so scan for those shapes in your screen output or use X-axis histogram score with Y as intensity. If enemies available location pixels are Red = 255 and if not pixel Red = 0. And voila... you got your enemies separated from the civilians. For specific circle, rectangle or square detection try openCV (cv2) in all other cases histrogram with small region (y1,y2; x1,x2) will work. – ZF007 Jun 20 '19 at 15:06
  • But doesn't PyAutoGUI use OpenCV in background? I installed it and pillow – Nv7 Jun 21 '19 at 00:41

1 Answers1

0

Try updating/installing openCV.

See this answer to similar a question: Documentation says to use a confidence parameter, but it throws an error

sushi
  • 274
  • 1
  • 4
  • 13