Reputation: 904
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
Upvotes: 8
Views: 4061
Reputation: 63
Not to grave dig old threads, but I ran into this. Try running your script as admin so if your running in CMD make sure you open it as administrator. It worked for me, very simple. I was using python, and windows 10.
Upvotes: 4
Reputation: 904
I tried out ctypes and that works:
ctypes.windll.user32.SetCursorPos(x, y)
Upvotes: 5