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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值