前提
Python3.8でpyautoguiというライブラリを用いて、カーソルを移動させる練習をしています。
x軸だけカーソルの座標を移動させるを実装中に以下のエラーメッセージが発生しました。
どなたか詳しい方がいらしたら、教えていただきたいです。
実現したいこと
pag.moveTo(500,None,3.5)
エラーがでるので、Noneを書き換えたい
発生している問題・エラーメッセージ
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-17-a10d7d70ed55> in <module> 11 12 # 3.5 秒かけてX のみ移動 ---> 13 pag.moveTo(500,None,3.5) 14 print("position{0}". format( pag. position())) 15 ~\Anaconda3\lib\site-packages\pyautogui\__init__.py in wrapper(*args, **kwargs) 596 def wrapper(*args, **kwargs): 597 failSafeCheck() --> 598 returnVal = wrappedFunction(*args, **kwargs) 599 _handlePause(kwargs.get("_pause", True)) 600 return returnVal ~\Anaconda3\lib\site-packages\pyautogui\__init__.py in moveTo(x, y, duration, tween, logScreenshot, _pause) 1278 None 1279 """ -> 1280 x, y = _normalizeXYArgs(x, y) 1281 1282 _logScreenshot(logScreenshot, "moveTo", "%s,%s" % (x, y), folder=".") ~\Anaconda3\lib\site-packages\pyautogui\__init__.py in _normalizeXYArgs(firstArg, secondArg) 699 ) 700 else: --> 701 return Point(int(firstArg), int(secondArg)) # firstArg and secondArg are just x and y number values 702 703 TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
該当のソースコード
Python
1# -* - coding: utf-8 -*- 2import pyautogui as pag #GUI操作毎のポーズ秒数 3 4# 3.5 秒かけてX のみ移動 5pag.moveTo(500,None,3.5) 6print("position{0}". format( pag. position()))
試したこと
pag.moveToの引数にはNoneがデェフォルトになっているので、何も書かずに入力してもエラーがでました。
Signature:
pag.moveTo(
x=None,
y=None,
duration=0.0,
tween=<function linear at 0x00000241C2B11798>,
logScreenshot=False,
_pause=True,
)
Docstring:
Moves the mouse cursor to a point on the screen.
The x and y parameters detail where the mouse event happens. If None, the
current mouse position is used. If a float value, it is rounded down. If
outside the boundaries of the screen, the event happens at edge of the
screen.
Args:
x (int, float, None, tuple, optional): The x position on the screen where the
click happens. None by default. If tuple, this is used for x and y.
If x is a str, it's considered a filename of an image to find on
the screen with locateOnScreen() and click the center of.
y (int, float, None, optional): The y position on the screen where the
click happens. None by default.
duration (float, optional): The amount of time it takes to move the mouse
cursor to the xy coordinates. If 0, then the mouse cursor is moved
instantaneously. 0.0 by default.
tween (func, optional): The tweening function used if the duration is not
0. A linear tween is used by default.
Returns:
None
File: c:\users\sd19080\anaconda3\lib\site-packages\pyautogui_init_.py
Type: function
回答1件
あなたの回答
tips
プレビュー