asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.45k stars 1.26k forks source link

Palliative correction of function locateOnWindow #654

Open hirios opened 2 years ago

hirios commented 2 years ago

What does this PR do?

Fix the pyautogui.locateOnWindow()

Why was it initiated?

When I tried to use this function, it returned a ValueError


  File "C:\Users\Administrator\Desktop\Teste\localize.py", line 21, in <module>                                         
    position = pyautogui.locateOnWindow('connect-wallet.png', title=title)                                              
  File "C:\Users\Administrator\Desktop\Teste\venv\lib\site-packages\pyautogui\__init__.py", line 175, in wrapper        
    return wrappedFunction(*args, **kwargs)                                                                             
  File "C:\Users\Administrator\Desktop\Teste\venv\lib\site-packages\pyautogui\__init__.py", line 219, in locateOnWindow 
    return pyscreeze.locateOnWindow(*args, **kwargs)                                                                    
  File "C:\Users\Administrator\Desktop\Teste\venv\lib\site-packages\pyscreeze\__init__.py", line 434, in locateOnWindow 
    return locateOnScreen(image, region=(win.left, win.top, win.width, win.height), **kwargs)                           
  File "C:\Users\Administrator\Desktop\Teste\venv\lib\site-packages\pyscreeze\__init__.py", line 373, in locateOnScreen 
    retVal = locate(image, screenshotIm, **kwargs)                                                                      
  File "C:\Users\Administrator\Desktop\Teste\venv\lib\site-packages\pyscreeze\__init__.py", line 353, in locate         
    points = tuple(locateAll(needleImage, haystackImage, **kwargs))                                                     
  File "C:\Users\Administrator\Desktop\Teste\venv\lib\site-packages\pyscreeze\__init__.py", line 219, in _locateAll_opencv                                                                                                                      
    raise ValueError('needle dimension(s) exceed the haystack image or region dimensions')                              
ValueError: needle dimension(s) exceed the haystack image or region dimensions   ```