Python Forum

Full Version: Pyautogui, İmagesearch, Moving target
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
"
while True:

p01 = imagesearch("p01.png")
        if p01[0] != -1:
            pyautogui.click(p01[0], p01[1])            (click)
            pyautogui.click(p01[0]+200, p01[1])    (range)
            time.sleep(5)                                         (approaching the target)
            pyautogui.press("space")                      (attack)
"

İ have simple code like this but i have a problem xd, as second command i make 200 unit right click of target,

When "p01" detects its target on the screen, for example 500x700, and if i repeat this line of code it constantly clicks on the 500x900 unit and moving away from target.

Since what I want to do is a "moving target", scanning the image continuously and having a distance of 200 units between the target and the target with variable coordinates.