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!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import time
import pyperclip
from PIL import Image
import pytesseract
import pyautogui
import pexpect
import win32com.client as comctl
im1 = pyautogui.screenshot(region = ( 0 , 0 , 100 , 100 ))
im1.save( "LieDetector.png" , grayscale = True )
pytesseract.pytesseract.tesseract_cmd = (
r "C:\Program Files (x86)\Tesseract-OCR\tesseract"
)
img = "LieDetector.png"
print (pytesseract.image_to_string(Image. open (img)))
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)))
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}" )
|