Python Forum
how to take a screnshot by Pyautogui automatically and randomly
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to take a screnshot by Pyautogui automatically and randomly
#1
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 :
[Image: 751Vm.png]

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")
        
buran write Feb-03-2021, 01:14 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pyaudio seems to randomly halt input. elpidiovaldez5 2 393 Jan-22-2024, 09:07 AM
Last Post: elpidiovaldez5
  Problem with code / audio is playing randomly, not matching csv requirements Daniel_kcr 2 643 Sep-07-2023, 05:09 PM
Last Post: deanhystad
  Pyautogui, İmagesearch, Moving target Beyazx 0 594 Jun-27-2023, 08:47 PM
Last Post: Beyazx
  PyautoGUI- How to use If - Else with pyautogui.locateCenterOnScreen Tiel 3 8,412 Jun-27-2022, 02:00 PM
Last Post: DeaD_EyE
  pyautogui.locateOnScreen producing error dude8074 6 3,865 Apr-17-2022, 05:05 PM
Last Post: bowlofred
Sad problem with Pyautogui rachidel07 1 2,478 Jan-27-2021, 05:43 PM
Last Post: nilamo
  pyautogui with a display emulator? gumby4231 0 2,612 Jul-30-2020, 02:46 PM
Last Post: gumby4231
  pyautogui.screenshot region is not working alexlu 6 6,530 Jun-04-2020, 10:46 AM
Last Post: alexlu
  loop in pyautogui (python automation GUI application) pyprogrammer 0 4,810 Feb-12-2020, 02:52 PM
Last Post: pyprogrammer
  Doesn't work function pyautogui.typewrite() aliyevmiras 1 4,820 Dec-22-2019, 11:35 AM
Last Post: aliyevmiras

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020