![]() |
how to take a screnshot by Pyautogui automatically and randomly - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: how to take a screnshot by Pyautogui automatically and randomly (/thread-32327.html) |
how to take a screnshot by Pyautogui automatically and randomly - rachidel07 - Feb-03-2021 objective i want to extract text from image. i play a game which an icon appears randomly ,and there is a text(text as image) near to the icon from the right. i want the script take screenshot of the region of the text only. so, i want the script every time he locatonscreen the i con, i want him take screen shot of the text. here is an image to understand the idea : ![]() this is my code: import pyautogui as py import time from PIL import Image from pytesseract import * pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe' while 1: indice1 = py.locateOnScreen("icon.png") if indice1: print("indice see it ") myScreenshot = py.screenshot() myScreenshot.save(r'C:\Users\rachidel07\Desktop\ok\venv\image.png') img=Image.open("image.png") output = pytesseract.image_to_string(img) print(output) else: print ("non") |