Feb-07-2021, 09:23 PM
i want to to locate an image on screen by "Pyautogui.locateOnScreen" but i want the region depend to the mouse. for example if the mouse in position x,y so i want to locate on screen from this x,y position .
another example: this is the code for locate-onscreen in a region: region=(100,100,100,100) what i want like this region=(my mouse position, Width , height).
image to explain more :
![[Image: 1IgRa.png]](https://i.stack.imgur.com/1IgRa.png)
this is my code
another example: this is the code for locate-onscreen in a region: region=(100,100,100,100) what i want like this region=(my mouse position, Width , height).
image to explain more :
![[Image: 1IgRa.png]](https://i.stack.imgur.com/1IgRa.png)
this is my code
import pyautogui import time time.sleep(5) while 1: img = pyautogui.locateOnScreen('test.png',confidence=0.8,region=(280,284,261,228)) if img: pyautogui.moveTo(img) time.sleep(2) pyautogui.moveRel(-196, 5) # pyautogui.locateOnScreen(here where i want add the region who depends on the mouse position ) ) else: print ('non')