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.5k stars 1.27k forks source link

Is this possible to use locateOnScreen against captured image file instead of screen image? #855

Closed tontoroRR closed 6 months ago

tontoroRR commented 7 months ago

What I am thinking is

  1. to capture screen image into png file(or any format).
  2. use locateOnScreen function to the captured image file as like below.
pyautogui.locateOnScreen('screenCapturedImage.png', 'button.png')

This is because I would like to use automated testing (with pytest) running on background without opening application windows.

Best regards,

tontoroRR commented 6 months ago

I found pyautogui.locate("screenCapturedImage.png", button.png") satisfies my purpose.