Pyautogui不在游戏风中工作

2024-10-05 10:37:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用Pyautogui在游戏上做一些测试。 但是在那些改变光标的游戏和全屏游戏中,这些方法都不起作用。在

我现在正在拉格纳罗网上试玩。在

我试过了:

pyautogui.click()
pyautogui.moveTo(x, y, time)
pyautogui.moveRel(x, y)

它们在游戏窗口内都不起作用。他们在外面工作得很好。在

有没有办法让它发挥作用?或者另一个我可以用的图书馆?在

顺便说一下,win32api.SetCursorPos((x,y))也不起作用。在

谢谢。在


Tags: 方法游戏图书馆timeclick全屏光标办法
1条回答
网友
1楼 · 发布于 2024-10-05 10:37:15

Pyautogui的源代码

def _sendMouseEvent(ev, x, y, dwData=0):
    assert x != None and y != None, 'x and y cannot be set to None'
    width, height = _size()
    convertedX = 65536 * x // width + 1
    convertedY = 65536 * y // height + 1
    ctypes.windll.user32.mouse_event(ev, ctypes.c_long(convertedX), ctypes.c_long(convertedY), dwData, 0)

它是一个win32API,内部调用SendInput。在

The SendInput function will insert input events into the same queue as a hardware device but the events are marked with a LLMHF_INJECTED flag that can be detected by hooks. To avoid this flag you probably have to write a custom driver.

关于如何在DirectX游戏中模拟键盘有很多答案和问题,有人说可以,也有人说不能。你可以试试这个an answer which say could

但在我看来,游戏必须使用directx接口与硬件进行通信以提高速度,那么SendInput只在消息中插入事件排队你想用SendInputMouse_Event。正如俗话所说

There's no problem that can't be solved with another level of indirection

让我们为游戏添加一个消息队列。在

怎么做的?VMware。完成了。在

相关问题 更多 >

    热门问题