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

added an exception error when using the wrong variable type in _moveto function #795

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pyautogui/_pyautogui_osx.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,5 +444,8 @@ def _dragTo(x, y, button):
time.sleep(pyautogui.DARWIN_CATCH_UP_TIME) # needed to allow OS time to catch up.

def _moveTo(x, y):
if (type(x) != int or type(y) != int):
raise Exception('The coordinates variable type must be int ')
_sendMouseEvent(Quartz.kCGEventMouseMoved, x, y, 0)
time.sleep(pyautogui.DARWIN_CATCH_UP_TIME) # needed to allow OS time to catch up.

3 changes: 3 additions & 0 deletions pyautogui/_pyautogui_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ def _moveTo(x, y):
Returns:
None
"""
if(type(x) != int or type(y) != int):
raise Exception('The coordinates variable type must be int ')
ctypes.windll.user32.SetCursorPos(x, y)
# This was a possible solution to issue #314 https://github.com/asweigart/pyautogui/issues/314
# but I'd like to hang on to SetCursorPos because mouse_event() has been superseded.
Expand Down Expand Up @@ -571,3 +573,4 @@ def _vscroll(clicks, x, y):
"""
return _scroll(clicks, x, y)


2 changes: 2 additions & 0 deletions pyautogui/_pyautogui_x11.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def _mouse_is_swapped():


def _moveTo(x, y):
if (type(x) != int or type(y) != int):
raise Exception('The coordinates variable type must be int ')
fake_input(_display, X.MotionNotify, x=x, y=y)
_display.sync()

Expand Down