鼠标输入
部分游戏会封闭鼠标输入,不能直接使用pyautogui等键盘输入,这时可以使用如下代码:
鼠标左键
def left_click():
extra = c_ulong(0)
ii_ = Input_I()
ii_.mi = MouseInput(0, 0, 0, 0x0002, 0, pointer(extra))
x = Input(c_ulong(0), ii_)
windll.user32.SendInput(1, pointer(x), sizeof(x))
extra = c_ulong(0)
ii_ = Input_I()
ii_.mi = MouseInput(0, 0, 0, 0x0004, 0, pointer(extra))
x = Input(c_ulong(0), ii_)
windll.user32.SendInput(1, pointer(x), sizeof(x))
鼠标右键
改变上面代码相应的值就可以了.
···
mouse_button_down_mapping = {
MouseButton.LEFT.name: 0x0002,
MouseButton.MIDDLE.name: 0x0020,
MouseButton.RIGHT.name: 0x0008
}
mouse_button_up_mapping = {
MouseButton.LEFT.name: 0x0004,
MouseButton.MIDDLE.name: 0x0040,
MouseButton.RIGHT.name: 0x0010
}
···
网友评论