【问题标题】:Python3 move mouse in DirectX gamesPython3 在 DirectX 游戏中移动鼠标
【发布时间】:2018-08-10 19:37:42
【问题描述】:

我正在尝试构建一个在 DirectX 游戏中执行一些操作的脚本。

除了移动鼠标之外,我已经完成了所有工作。

是否有任何可以移动鼠标的模块,适用于 windows (python 3)

谢谢!

【问题讨论】:

    标签: python windows python-3.x directx


    【解决方案1】:

    我在 Python 2.7 中使用过一次pynput。我刚刚在 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 游戏中成功测试。

    【讨论】:

    • 我想在3D第三人称游戏中使用这个方法,我试过这个方法很遗憾它没有响应。
    • 究竟是哪个游戏?或者是哪个引擎?也许我可以帮助/测试一下。
    【解决方案2】:

    使用名为 sikulix 的免费软件应用程序。它会为你创造奇迹

    【讨论】:

    • 他正在尝试自己编写代码。我认为在这种情况下这个答案有点多余:)
    • 会调查,但我宁愿不使用 pyhon 以外的其他工具。
    猜你喜欢
    • 2012-06-02
    • 2012-12-15
    • 2017-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多