Disclaimer- I am new to coding and just started learning not long ago so don't judge me for the code, thanks.
I made a bot for my game to do some particular tasks but problem is that it uses pyautogui and pytessarect but in order to run the program the game should be on the screen means i can't do anything on the system if i need that program to run.
So I was wondering is there any way to run the code with game in the background so i can use my system in the meantime
Here is the code
import pyautogui
pyautogui.FAILSAFE=False
import time
import keyboard
from pyautogui import *
import pytesseract as tess
from pygame.event import get_grab
tess.pytesseract.tesseract_cmd = r'C:\Users\arshi_k8rjg1x\AppData\Local\Tesseract-OCR\tesseract'
from PIL import Image, ImageGrab
a = input("Name of pokemon:")
name="VS. "+"Wild "+a+'\n'
b = input("Name of pokemon:")
name1="VS. "+"Wild "+b+'\n'
c = input("Name of pokemon:")
name2="VS. "+"Wild "+c+'\n'
time.sleep(3)
def movement():
while pyautogui.pixel(1248, 496)[0] != 27 and [1] != 25 and [2] != 27:
pyautogui.keyDown('D')
time.sleep(0.05)
pyautogui.keyUp('D')
time.sleep(0.05)
pyautogui.keyDown('A')
time.sleep(0.05)
pyautogui.keyUp('A')
img = ImageGrab.grab(bbox=(831, 320, 1100, 350))
text = tess.image_to_string(img)
if text == name or text==name1 or text==name2:
time.sleep(6)
attack()
else:
pyautogui.keyDown('4')
time.sleep(0.5)
pyautogui.keyUp('4')
time.sleep(2)
movement()
def attack():
pyautogui.keyDown('1')
time.sleep(0.3)
pyautogui.keyUp('1')
time.sleep(0.3)
pyautogui.keyDown('3')
time.sleep(0.3)
pyautogui.keyUp('3')
time.sleep(9)
pyautogui.keyDown('3')
time.sleep(0.3)
pyautogui.keyUp('3')
time.sleep(0.3)
pyautogui.keyDown('1')
pyautogui.keyUp('1')
movement()
movement()