Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error With locateCenterOnScreen #49

Open
Croq360 opened this issue May 2, 2019 · 2 comments · May be fixed by #51
Open

Error With locateCenterOnScreen #49

Croq360 opened this issue May 2, 2019 · 2 comments · May be fixed by #51

Comments

@Croq360
Copy link

Croq360 commented May 2, 2019

With the current code, if you try to do locateCenterOnScreen(), and you are using the default "return None" approach, you get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python\Python37\lib\site-packages\pyscreeze\__init__.py", line 319, in locateCenterOnScreen
    return center(coords)
  File "C:\Python\Python37\lib\site-packages\pyscreeze\__init__.py", line 427, in center
    return Point(coords[0] + int(coords[2] / 2), coords[1] + int(coords[3] / 2))
TypeError: 'NoneType' object is not subscriptable

This can be corrected by changing the center() function to read:

def center(coords):
    if coords is None:
        return coords
    else:
        return Point(coords[0] + int(coords[2] / 2), coords[1] + int(coords[3] / 2))
@snoopyjc
Copy link

snoopyjc commented May 9, 2019

Exactly!!! I'm using an avoidance by putting a "try" block around every call!

@KerbalSpaceFrontier
Copy link

This would be a nice fix. I ended up adding an if statement to locateCenterOnScreen() originally, but this makes more sense, since center could eventually be used in another method.

bugchecker added a commit to bugchecker/pyscreeze that referenced this issue Sep 26, 2019
bugchecker added a commit to bugchecker/pyscreeze that referenced this issue Sep 26, 2019
bugchecker added a commit to bugchecker/pyscreeze that referenced this issue Oct 3, 2019
bugchecker added a commit to bugchecker/pyscreeze that referenced this issue Oct 3, 2019
bugchecker added a commit to bugchecker/pyscreeze that referenced this issue Oct 3, 2019
@bugchecker bugchecker linked a pull request Oct 3, 2019 that will close this issue
bugchecker added a commit to bugchecker/pyscreeze that referenced this issue Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants