Mar-03-2019, 06:01 AM
I'm very new to python (programming in general). I play a game called maplestory that has occasional "bot" checks that requires you to type in a 8 digit numerical captcha. This script works on the desktop screen, however, my pyautogui and wsh click and keystrokes will not work on my video game window. I must be going the wrong way about this. Any suggestions would be great!
import time import pyperclip from PIL import Image import pytesseract import pyautogui import pexpect import win32com.client as comctl #Find Image and Save im1 = pyautogui.screenshot(region=(0, 0, 100, 100)) im1.save("LieDetector.png", grayscale=True) #OCR prints to .txt pytesseract.pytesseract.tesseract_cmd = ( r"C:\Program Files (x86)\Tesseract-OCR\tesseract" ) img = "LieDetector.png" print(pytesseract.image_to_string(Image.open(img))) #Saves OCR data to clipboard with open ("LieDetector.txt", "w") as text_file: text_file.write(pytesseract.image_to_string(Image.open(img))) pyperclip.copy(pytesseract.image_to_string(Image.open(img))) #Paste clipboard to video game Captcha pyautogui.click(284, 60) time.sleep(1) pyautogui.click() time.sleep(1) wsh = comctl.Dispatch("WScript.Shell") wsh.SendKeys("^{v}") time.sleep(1) wsh.SendKeys("{ENTER}")