Python3 move mouse in DirectX games

痴心易碎 提交于 2019-12-11 12:09:43

问题


I'm trying to build create a script that does a few action inside an DirectX game.

I've got everything working exept for moving the mouse.

Is there any module avalable that can move the mouse, for windows (python 3)

Thanks!


回答1:


I used pynput once in Python 2.7. I just checked under Python 3.7 and it moves the cursor alright. Sample code from linked source:

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)

Edit: Just successfully tested in a DirectX game.




回答2:


Use a freeware App called sikulix. It will do wonders for you



来源:https://stackoverflow.com/questions/51793103/python3-move-mouse-in-directx-games

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!