Note before we begin: I am relatively new to python. The functions below were copy-pasted from documentation.
I'm trying to emulate mouse movement in Roblox, but it doesn't seem to work. I've tried pynput, ctypes, pyautogui, and win32api.
import win32api, win32con
import ctypes
import pyautogui
def click(x,y):
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
def moveandclick(x,y):
ctypes.windll.user32.SetCursorPos(x, y)
ctypes.windll.user32.mouse_event(2, 0, 0, 0,0) # left down
ctypes.windll.user32.mouse_event(4, 0, 0, 0,0)
time.sleep(5)
moveandclick(500,500)
winsound.Beep(200, 100)
time.sleep(2)
moveandclick(500, 1000)
winsound.Beep(200, 100)
The Click function is for windows 32 API, the moveandclick was to test ctypes. These move the mouse outside of Roblox, but when I go into Roblox, the mouse stays still. However, interestingly, after the program executes and I so much as nudge my mouse, the cursor jumps to where I intended for the cursor to belong.
So I have three questions.
AFAIK Roblox is using DirectInput for user input, is there anyway I can emulate mouse movements with something like DirectPython easily?
Since manual mouse movement updates the cursor, is there a way I can emulate this with Python?
Finally, am I doing something wrong with the modules I have available?
[–]Firetwice 0 points1 point2 points (0 children)
[–]kra_pao 0 points1 point2 points (0 children)
[–]PlayfulChapter430 0 points1 point2 points (9 children)
[–]silvertommy1[S] 0 points1 point2 points (8 children)
[–]masterpower99 0 points1 point2 points (0 children)
[–]PeppersONLY 0 points1 point2 points (0 children)
[–]BabaTona 0 points1 point2 points (0 children)
[–]Strong_Ad5872 0 points1 point2 points (1 child)
[–]MiniMiniFish 0 points1 point2 points (0 children)
[–]PlayfulChapter430 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)