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

The example pyautogui.click('button.png') in readthedocs does not work #908

Open
douglasdcm opened this issue Jan 17, 2025 · 0 comments
Open

Comments

@douglasdcm
Copy link

Hi, how are you? I'm following the examples from readthedocs and I noticed this syntax pyautogui.click('button.png') is not working. I had the following error when running it. I had to use the locate functions like here

Error

examples/linux_desktop/pyautogui/test_sample.py::test_pyauto_gui FAILED

================================== FAILURES ==================================
______________________________ test_pyauto_gui _______________________________

    def test_pyauto_gui():
        screenWidth, screenHeight = pyautogui.size()  # Get the size of the primary monitor.
        screenWidth, screenHeight
    
        currentMouseX, currentMouseY = (
            pyautogui.position()
        )  # Get the XY position of the mouse.
        currentMouseX, currentMouseY
    
        # pyautogui.moveTo(100, 150)  # Move the mouse to XY coordinates.
    
        # pyautogui.click()  # Click the mouse.
        # pyautogui.click(100, 200)  # Move the mouse to XY coordinates and click it.
        img_path = "/home/douglas/repo/guara/examples/linux_desktop/pyautogui/button.png"
>       pyautogui.click(img_path)

examples/linux_desktop/pyautogui/test_sample.py:18: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
venv/lib/python3.11/site-packages/pyautogui/__init__.py:594: in wrapper
    returnVal = wrappedFunction(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

x = '/home/douglas/repo/guara/examples/linux_desktop/pyautogui/button.png'
y = None, clicks = 1, interval = 0.0, button = 'left', duration = 0.0
tween = <function linear at 0x7fb23362c540>, logScreenshot = None
_pause = True

    @_genericPyAutoGUIChecks
    def click(
        x=None, y=None, clicks=1, interval=0.0, button=PRIMARY, duration=0.0, tween=linear, logScreenshot=None, _pause=True
    ):
        """
        Performs pressing a mouse button down and then immediately releasing it. Returns ``None``.
    
        When no arguments are passed, the primary mouse button is clicked at the mouse cursor's current location.
    
        If integers for ``x`` and ``y`` are passed, the click will happen at that XY coordinate. If ``x`` is a string, the
        string is an image filename that PyAutoGUI will attempt to locate on the screen and click the center of. If ``x``
        is a sequence of two coordinates, those coordinates will be used for the XY coordinate to click on.
    
        The ``clicks`` argument is an int of how many clicks to make, and defaults to ``1``.
    
        The ``interval`` argument is an int or float of how many seconds to wait in between each click, if ``clicks`` is
        greater than ``1``. It defaults to ``0.0`` for no pause in between clicks.
    
        The ``button`` argument is one of the constants ``LEFT``, ``MIDDLE``, ``RIGHT``, ``PRIMARY``, or ``SECONDARY``.
        It defaults to ``PRIMARY`` (which is the left mouse button, unless the operating system has been set for
        left-handed users.)
    
        If ``x`` and ``y`` are specified, and the click is not happening at the mouse cursor's current location, then
        the ``duration`` argument is an int or float of how many seconds it should take to move the mouse to the XY
        coordinates. It defaults to ``0`` for an instant move.
    
        If ``x`` and ``y`` are specified and ``duration`` is not ``0``, the ``tween`` argument is a tweening function
        that specifies the movement pattern of the mouse cursor as it moves to the XY coordinates. The default is a
        simple linear tween. See the PyTweening module documentation for more details.
    
        The ``pause`` parameter is deprecated. Call the ``pyautogui.sleep()`` function to implement a pause.
    
        Raises:
          PyAutoGUIException: If button is not one of 'left', 'middle', 'right', 1, 2, 3
        """
        # TODO: I'm leaving buttons 4, 5, 6, and 7 undocumented for now. I need to understand how they work.
        button = _normalizeButton(button)
>       x, y = _normalizeXYArgs(x, y)
E       TypeError: cannot unpack non-iterable NoneType object

venv/lib/python3.11/site-packages/pyautogui/__init__.py:985: TypeError
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

No branches or pull requests

1 participant