的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
內部。
的SendInput
功能將插入輸入事件到同一隊列爲硬件設備,但這些事件被標記與可由鉤來檢測一個LLMHF_INJECTED
標誌。爲了避免這個標誌,你可能必須寫一個自定義驅動程序。
有很多答案,以及如何在DirectX遊戲模擬鍵盤的問題,其中一些可能說有些人說可能not.and,你可以嘗試這個an answer which say could
但在我看來,遊戲必須使用DirectX接口與硬件的速度通信,那麼SendInput
只能插入事件到消息queue.and要使用SendInput
或Mouse_Event
。所以俗話說,
沒有什麼問題不能得到解決另一級o f間接
讓我們爲遊戲添加一個消息隊列。
怎麼樣?VMware.It完成了。