I’m working on automating a minigame in GTA using Python. Currently, I’m using the pydirectinput library, but I’m having trouble moving the camera within the game. When the code runs outside of GTA, my mouse moves correctly. However, inside the game, the mouse doesn’t move properly. The mouse will randomly move 1 -3 times without me being able to figure out why.
Here’s the code I’m using.
import pyautogui
import pynput
print("Starting")
pyautogui.sleep(8)
location = pydirectinput.position()
mouse = pynput.mouse.Controller()
mouse.move(120, 50)
print("Move 1")
pyautogui.sleep(1)
mouse.move(120, 50)
print("Move 2")
pyautogui.sleep(1)
mouse.move(120, 50)
print("Move 3")
pyautogui.sleep(1)
mouse.move(120, 50)
print("Move 4")
pyautogui.sleep(1)
mouse.move(120, 50)
print("Move 5")
pyautogui.sleep(1)
mouse.move(120, 50)
print("Move 6")
New contributor
white light is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.