question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I think locateCenterOnScreen is broken

See original GitHub issue
def locateCenterOnScreen(image, **kwargs):
    coords = locateOnScreen(image, **kwargs)
    return center(coords)

and

def center(coords):
    return Point(coords[0] + int(coords[2] / 2), coords[1] + int(coords[3] / 2))

when image is not found. Then an error occurs: File "C:\Users\Yasin\PycharmProjects\venv\lib\site-packages\pyscreeze\__init__.py", line 333, in locateCenterOnScreen return center(coords) File "C:\Users\Yasin\PycharmProjects\venv\lib\site-packages\pyscreeze\__init__.py", line 448, in center return Point(coords[0] + int(coords[2] / 2), coords[1] + int(coords[3] / 2)) TypeError: 'NoneType' object is not subscriptable

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
chaotianjiaocommented, Aug 14, 2019

@yasinalp Thank you and best wishes!

1reaction
yasinalpcommented, Aug 13, 2019

Yes! Define those functions and use findCenterOnScreen instead locateCenterOnScreen 😃 findCenterOnScreen should have the same arguments with locateCenterOnScreen.

def findCenterOnScreen():
    found = locateOnScreen()
    if found:
        cx, cy = centeredCoords(found)
        return cx, cy
    else:
        return None


def centerCoords(_coords):
    return _coords[0] + int(_coords[2] / 2), _coords[1] + int(_coords[3] / 2)
Read more comments on GitHub >

github_iconTop Results From Across the Web

pyautogui.locateCenterOnScreen() returns None instead of ...
My problem is Solved when I took screenshot by pyautogui inbuilt function rather than taking WIN + Printscr because if we took screenshot...
Read more >
Pyautogui LocateOnScreen not working - Python Help
I tried creating a program where when you run the program it opens a new tab This is my program: import pyautogui as...
Read more >
Python Code not working outside of PyCharm - Reddit
locatecenteronscreen, works. for some reason it wont click the located center on screen, unless its in pycharm, is it possible for me to...
Read more >
pyautogui.locateOnScreen producing error - Python Forum
I'm thinking its probably an error with my math to calculate xregion , yregion , length , and height .
Read more >
pyautogui multiple monitors
locateCenterOnScreen () is also affected if you change your screen size in your system ... I guess you have opencv3.0+ and python3 installed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found