我正在尝试构建一个在 DirectX 游戏中执行一些操作的脚本。
除了移动鼠标之外,我一切都正常。
是否有任何可用的模块可以移动鼠标,适用于 Windows (python 3)
Thanks!
I used pynput https://pypi.org/project/pynput/Python 2.7 中曾经出现过一次。我刚刚在 Python 3.7 下检查过,它可以正常移动光标。来自链接源的示例代码:
from pynput.mouse import Button, Controller
mouse = Controller()
# Read pointer position
print('The current pointer position is {0}'.format(
mouse.position))
# Set pointer position
mouse.position = (10, 20)
print('Now we have moved it to {0}'.format(
mouse.position))
# Move pointer relative to current position
mouse.move(5, -5)
# Press and release
mouse.press(Button.left)
mouse.release(Button.left)
# Double click; this is different from pressing and releasing
# twice on Mac OSX
mouse.click(Button.left, 2)
# Scroll two steps down
mouse.scroll(0, 2)
编辑:刚刚在 DirectX 游戏中成功测试。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)