我试图将鼠标移动到FPS游戏中(比如valorant/csgo),但不起作用。我使用了PyAutoGui、PyInput、鼠标、PyWin32和许多其他语言库,但我只能模拟点击。我看到了一些关于拦截(由斜方体)和几年前的工作,但这一天没有。游戏阻止了这一拦截。
,所以我想我需要建立一些驱动程序拦截,在鼠标中移动。另一个窍门是使用Arduino (这些日子起作用了),但是对于我的项目来说,这不是一个解决方案。我只需要在蟒蛇和任何鼠标。
发布于 2022-09-15 10:21:28
这取决于您要如何移动鼠标。我猜是根据你想要移动的吗?如果是这样,请尝试第一段代码,因为第二段代码基于一系列命令执行。
你试过@flipeador的这代码吗?
#from interception import Interception, MouseFilter, KeyFilter, MouseFlags,\
# MouseState, KeyState, MapVk, Vk, map_virtual_key
RUNNING = True
TIMEOUT = 2500 # ms
interception = Interception()
interception.set_mouse_filter(MouseFilter.ButtonAll)
interception.set_keyboard_filter(KeyFilter.All)
while RUNNING:
device = interception.wait_receive(TIMEOUT)
if device:
print(f'{device.get_hardware_id()}:')
# Mouse
if device.is_mouse:
print('MouseStroke(flags={1},state={2},rolling={0.rolling},x={0.x},y={0.y},info={0.info})'
.format(device.stroke, MouseFlags(device.stroke.flags).name, MouseState(device.stroke.state).name))
# Keyboard
elif device.is_keyboard:
vk = map_virtual_key(device.stroke.code, MapVk.ScToVk)
print('KeyStroke(sc={0.code:03X},vk={2:03X},state={1},info={0.info})'
.format(device.stroke, KeyState(device.stroke.state).name, vk))
# escape = terminate
if vk == Vk.Escape:
RUNNING = False
# switch x and y
elif vk == Vk.X:
device.stroke.code = map_virtual_key(Vk.Y, MapVk.VkToSc)
elif vk == Vk.Y:
device.stroke.code = map_virtual_key(Vk.X, MapVk.VkToSc)
device.send()
print('-'*100)
请注意,您是不允许在Valorant中作弊,因为它阻止了许多“黑客”,并检测您的黑客行为,即使您使用的程序不在他们的阻止列表中。
发布于 2022-09-12 13:21:24
我不是来质疑你的道德。一定要走arduino路线(你可能需要两条路)。一个接收python命令,另一个模拟鼠标事件。取决于arduino),并确保在任何地方都使用一些随机化。
我很怀疑你为什么想要这个。我看不出作弊有什么乐趣,我也看不出你这样做的目的是什么。
发布于 2022-09-13 10:42:02
虽然您说它对您不起作用,但是您想要使用的包是pynput。可以像文档中所说的那样模拟鼠标的移动和点击。
from pynput.mouse import Button, Controller
mouse = Controller()
# Move pointer relative to current position
mouse.move(5, -5)
这应该会给你你想要的行为。
编辑:在防作弊软件到位,这可能是非常困难(更不用说不可能)模拟鼠标在游戏中的移动。该游戏可以区分有机鼠标运动和模拟运动。单靠Python可能无法使Valorant相信您的鼠标移动是“真实的”;)
https://stackoverflow.com/questions/73609639
复制相似问题