Python Forum
pyautogui screenshotting region relative to image found on screen
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pyautogui screenshotting region relative to image found on screen
#4
i figured out a way to do it however it is now saying too many indices for array for
oil1[0]
food1 = numpy.array(foodi)

food1[0] += 32
food1[1] += 7
food1[2] += 30
food1[3] -= 10

food = pyautogui.screenshot(region=(food1[0], food1[1], food1[2], food1[3]))
food.save(r'C:\Users\brady\PycharmProjects\Bot\foodc.png')

def get_text(image):
    return pytesseract.image_to_string(image)
img = Image.open('foodc.png')
print(pytesseract.image_to_string(img))
time.sleep(1)
oil1 = numpy.array(oili)

oil1[0] += 32
oil1[1] += 7
oil1[2] += 30
oil1[3] -= 10

oil = pyautogui.screenshot(region=(oil1[0], oil1[1], oil1[2], oil1[3]))

oil.save(r'C:\Users\brady\PycharmProjects\Bot\oilc.png')

(Oct-05-2019, 06:20 PM)Bmart6969 Wrote: i figured out a way to do it however it is now saying too many indices for array for
oil1[0]
food1 = numpy.array(foodi)

food1[0] += 32
food1[1] += 7
food1[2] += 30
food1[3] -= 10

food = pyautogui.screenshot(region=(food1[0], food1[1], food1[2], food1[3]))
food.save(r'C:\Users\brady\PycharmProjects\Bot\foodc.png')

def get_text(image):
    return pytesseract.image_to_string(image)
img = Image.open('foodc.png')
print(pytesseract.image_to_string(img))
time.sleep(1)
oil1 = numpy.array(oili)

oil1[0] += 32
oil1[1] += 7
oil1[2] += 30
oil1[3] -= 10

oil = pyautogui.screenshot(region=(oil1[0], oil1[1], oil1[2], oil1[3]))

oil.save(r'C:\Users\brady\PycharmProjects\Bot\oilc.png')

This code worked on my scratch file when I copied it over to my Main project it started giving me this error.
Reply


Messages In This Thread
RE: pyautogui screenshotting region relative to image found on screen - by Bmart6969 - Oct-05-2019, 06:20 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pyautogui, İmagesearch, Moving target Beyazx 0 616 Jun-27-2023, 08:47 PM
Last Post: Beyazx
  Using locationtagger to extract locations found in a specific country/region lord_of_cinder 1 1,317 Oct-04-2022, 12:46 AM
Last Post: Larz60+
  PyautoGUI- How to use If - Else with pyautogui.locateCenterOnScreen Tiel 3 8,566 Jun-27-2022, 02:00 PM
Last Post: DeaD_EyE
  pyautogui.locateOnScreen producing error dude8074 6 3,959 Apr-17-2022, 05:05 PM
Last Post: bowlofred
  How to reference the relative directory when creating a photoimage kenwatts275 3 6,510 May-18-2021, 07:22 PM
Last Post: menator01
  how to take a screnshot by Pyautogui automatically and randomly rachidel07 0 3,590 Feb-03-2021, 01:16 PM
Last Post: rachidel07
Sad problem with Pyautogui rachidel07 1 2,507 Jan-27-2021, 05:43 PM
Last Post: nilamo
  How can I found how many numbers are there in a Collatz Sequence that I found? cananb 2 2,587 Nov-23-2020, 05:15 PM
Last Post: cananb
  Add new line after finding last string in a region Nigel11 1 1,923 Aug-08-2020, 10:00 PM
Last Post: Larz60+
  pyautogui with a display emulator? gumby4231 0 2,644 Jul-30-2020, 02:46 PM
Last Post: gumby4231

Forum Jump:

User Panel Messages

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