#please help me with the pyautogui LocateCenterOnScreen [ Solved]

17 messages · Page 1 of 1 (latest)

tame grove
#

Hello, I'm a beginner in python and I'm trying to use pyautogui with LocanteCenterOnScreen, but it doesn't return anything and the code is normal, does anyone know what I can do?

browser_icon = py.locateCenterOnScreen('imagens/browser.png')
py.moveTo(browser_icon, duration = 2)

the mouse does not move to the requested location

┌─[dan@parrot]─[~/Desktop/project]
└──╼ $

eternal isle
#

Can you print out the browser_icon to see if that's giving you anything, and can you share your full code?

#

Also, have you installed and imported PyAutoGui? @tame grove

eternal isle
#

And, that seems to be a venv shell

#

So you'd have to install it to the virtual environment you're using

mental radish
#

It's possible that the image file imagens/browser.png is not being found by the program. Make sure that the image file is located in the correct directory and that the file name is spelled correctly. You can also try specifying the full file path instead of just the file name. Additionally, you can try adjusting the confidence parameter of the locateCenterOnScreen function to improve the accuracy of the image matching.

viral nebula
# mental radish It's possible that the image file `imagens/browser.png` is not being found by th...
GitHub

PyScreeze is a simple, cross-platform screenshot module for Python 2 and 3. - pyscreeze/init.py at b693ca9b2c964988a7e924a52f73e15db38511a8 · asweigart/pyscreeze

#

Seems your second suggestion is perhaps more applicable

#

What is the value of browser_icon?

mental radish
#

The value of browser_icon is the center coordinates of the image 'imagens/browser.png' on the screen, as returned by the locateCenterOnScreen function. If the image is not found on the screen, the function will return None.

viral nebula
#

oh, I misunderstood, not found on screen vs not found in file system

#

lots of ways to not find an image apparently

tame grove
tame grove
tame grove
#

I still haven't found anything that can solve this problem 😦

#

I was able to find the problem, the linux system was updated, so locatecenterOnscreen was unable to access the GUI. I did the update and it worked, Thanks Guys