[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
前言:
在python关于按键精灵得操作中常用的有PyAutoGUI,但在使用的过程中,针对一些游戏就直接失灵了,特别是一些以DirectX来开发的游戏或软件。我通过收索相关资料了解到之所以会这样,是因为PyAutoGUI使用的是 Virtual
Key Codes
(VKs),也就是模拟按键码。而对于这些游戏或软件来说需要使用Directinput,这样就需要直接从设备中获取数据,而不是模拟的。而这个由github上Ben
Johnson开发的 PyDirectInput库就是针对此而设计的。
库安装:
pip install pydirectinput
使用:
import pydirectinput pydirectinput.moveTo(100, 150) # 移动鼠标至坐标100,150
pydirectinput.click() # 点击鼠标左键 pydirectinput.click(200, 220) #
移动鼠标至坐标200,220,并点击左键 pydirectinput.move(None, 10) # 鼠标移动相对y位置
pydirectinput.doubleClick() # 双击鼠标左键 pydirectinput.press('esc') # 按一下esc
pydirectinput.keyDown('shift')#按下shift pydirectinput.keyUp('shift')#弹起shift
截至目前还未完成的功能:
1.鼠标滚轮操作
2.拖拽功能
3.热键功能
4.一些特殊shift搭配的按键比如字符(ie. '!', '@', '#'等)
5.鼠标速度设置,跟随,截图等功能
6.按键截图