Screen Recognition (Locating Images on Screen)
Concept
You take a small screenshot of a button (template image), then search for it on screen.
Example
locate_image.py
import pyautogui
# button_pos = pyautogui.locateCenterOnScreen("button.png", confidence=0.9)
# if button_pos:
# pyautogui.click(button_pos)locate_image.py
import pyautogui
# button_pos = pyautogui.locateCenterOnScreen("button.png", confidence=0.9)
# if button_pos:
# pyautogui.click(button_pos)Notes
confidenceconfidencerequires OpenCV support- matching can fail due to scaling/themes
If this helped you, consider buying me a coffee ☕
Buy me a coffeeWas this page helpful?
Let us know how we did
