python对第3方软件进行操作,可以采用下面的方式。
1 win32,PyAutoGUI安装
pip install pypiwin32
pip install PyAutoGUI
2 操作方式
- 打开软件(如果软件已打开,需要先关闭)
- 进行操作
- 关闭软件
代码如下:
#!/usr/bin/env python3
3 如果软件不能关闭,需要将第3方软件置顶,采用下面代码:
hwnd
4 通过定位坐标进行按键操作(类似按键精灵)
# 50, 350为目标对象的坐标
pyautogui.moveTo(50, 350, duration=0.2, tween=pyautogui.easeInOutQuad)
pyautogui.click(clicks=1)
参考:
PyAutoGUI
Python win32gui SetAsForegroundWindow function not working properly
https://blog.csdn.net/qq_16234613/article/details/79155632
https://stackoverflow.com/questions/42370339/python-3-6-install-win32api/42400980
https://blog.csdn.net/smallsmallmouse/article/details/78689675