Program prevents mouse movement

python, python-3.x, winapi

Solution

I tried out ctypes and that works:

ctypes.windll.user32.SetCursorPos(x, y)

Problem

I have a click bot for a game and haven't used it for a while. I installed it new(maybe there was a new version) and my bot isn't working anymore. It seems like the event is somehow blocked when the game is activated. I activate the game, with this: ``` shell=win32com.client.Dispatch("Wscript.Shell") success = shell.AppActivate("Game) ``` I tried 2 methods to move the mouse: ``` win32api.SetCursorPos((x,y)) ``` That gives me this error. ``` pywintypes.error: (0, 'SetCursorPos', 'No error message is available') ``` The other method is: ``` nx = int(x*65535/win32api.GetSystemMetrics(0)) ny = int(y*65535/win32api.GetSystemMetrics(1)) win32api.mouse_event(win32con.MOUSEEVENTF_ABSOLUTE|win32con.MOUSEEVENTF_MOVE,nx,ny) ``` which doesn't work and doesn't give me an error message. When the game window is not activated, the cursor moves without a problem. Does anybody know a workaround for this? Edit: I am using Microsoft Windows 8.1

Original source