python模拟按键directx,Python3在DirectX游戏中移动鼠标
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!
解決方案
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.
總結(jié)
以上是生活随笔為你收集整理的python模拟按键directx,Python3在DirectX游戏中移动鼠标的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前端学习之浏览器缓存
- 下一篇: 浏览器缓存及实现原理