程序阻止鼠标移动 [英] Program prevents mouse movement

查看:38
本文介绍了程序阻止鼠标移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于游戏的点击机器人,但有一段时间没有使用它.我安装了新的(也许有一个新版本),我的机器人不再工作了.似乎在游戏激活时该事件以某种方式被阻止了.

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.

我用这个激活游戏:

shell=win32com.client.Dispatch("Wscript.Shell")
success = shell.AppActivate("Game)

我尝试了两种移动鼠标的方法:

I tried 2 methods to move the mouse:

win32api.SetCursorPos((x,y)) 

这给了我这个错误.

pywintypes.error: (0, 'SetCursorPos', 'No error message is available')

另一种方法是:

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.

有人知道解决方法吗?

我使用的是 Microsoft Windows 8.1

I am using Microsoft Windows 8.1

推荐答案

我尝试了 ctypes 并且有效:

I tried out ctypes and that works:

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

这篇关于程序阻止鼠标移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆