I know that PyAutoGUI and Pynput can read mouse inputs, but they can only read your coordinates on the screen. I’m trying to create a macro recorder but I need to be able to read the input being communicated to my computer rather than reading the current position of my mouse.
I’m trying to make a macro recorder for the game Minecraft, which has its screen locked in the centre of the screen. I believe that when you move your mouse it shifts its position a little bit and then returns back to the centre of the screen. I’ve tried basing my code around that but it ended up a little “finnicky”:
import pyautogui
import time
x_coords = []
y_coords = []
base_position_x, base_position_y = pyautogui.position()
while True:
current_position_x, current_position_y = pyautogui.position()
change_x = current_position_x - base_position_x
change_y = current_position_y - base_position_x
x_coords.append(change_x)
y_coords.append(change_y)
base_position_x, base_position_y = current_position_x, current_position_y
time.sleep(0.01)
and then I did something like this:
for x, y in zip(x_coords, x_coords)
pyautogui.move(x, y)
time.sleep(0.01)
It ended up very slow and jittery, so I thought trying to take the “raw” mouse inputs would have been a lot easier to code.
fofo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.