i am using pixelstudio to animate some things. I am able to automate it. However, the pyautogui keypresses and mouse drag interactions are not working. The clicks work, but the dragging to highlight and the keyboard arrow presses do not. I tested the code on my desktop - the clicks and keyboard moves and dragging to highlight all works fine, but once I get into the drawing system only the clicks do. What is causing this issue and is there a way to fix it? Thanks! (code is shown below for reference)
# auto twitch animation for da rest of it
import pyautogui as pag
import keyboard
# failsafe pls dont mess up
while True:
if keyboard.is_pressed("q"):
break
else:
pag.sleep(3)
# click gear 2355 50
pag.leftClick(2355, 50)
pag.sleep(1)
# clone frame 1131 1039
pag.leftClick(1131, 1039)
pag.sleep(1)
# click layer 2 twice 242 1387
pag.leftClick(242, 1387)
pag.sleep(1)
pag.leftClick(242, 1387)
pag.sleep(1)
# highlight clouds - two right 582 109 - 2414 494 leftClick, dragTo left (x,y,t,button="left)
pag.moveTo(582, 109)
pag.sleep(1)
pag.mouseDown(button="left")
pag.moveTo(2414, 494, 1)
pag.mouseUp(button="left")
pag.sleep(1)
pag.press("right")
pag.sleep(1)
pag.press("right")
pag.sleep(1)
# highlight bottom cloud - two left 1013 973 - 111 803
pag.moveTo(1013, 973)
pag.sleep(1)
pag.mouseDown(button="left")
pag.moveTo(111, 803, 1)
pag.mouseUp(button="left")
pag.sleep(1)
pag.press("left")
pag.sleep(1)
pag.press("left")
pag.sleep(1)
# plane four left 1029 474 - 112 622
pag.moveTo(1029, 474)
pag.sleep(1)
pag.mouseDown(button="left")
pag.moveTo(112, 622, 1)
pag.mouseUp(button="left")
pag.sleep(1)
pag.press("left")
pag.sleep(1)
pag.press("left")
pag.sleep(1)
pag.press("left")
pag.sleep(1)
pag.press("left")
pag.sleep(1)
# plane four right 1450 656 - 2402 821
pag.moveTo(1450, 656)
pag.sleep(1)
pag.mouseDown(button="left")
pag.moveTo(2402, 821, 1)
pag.mouseUp(button="left")
pag.sleep(1)
pag.press("right")
pag.sleep(1)
pag.press("right")
pag.sleep(1)
pag.press("right")
pag.sleep(1)
pag.press("right")
pag.sleep(1)
Use pydirectinput library. If anyone else has this issue - it is due to pyautogui's old system of simulating keypresses and mouse buttons. It makes it not work with certain games and programs especially newer ones. Install the pydirectinput library, input it into the code and replace the pyautogui prefix with pydirectinput.