1.安装 pywinauto
pip install pywinauto
2.打开PC的.exe可执行文件的,一种方式就够用了
from pywinauto importapplication
app= application.Application().start('notepad.exe')
效果:
3.可以看到窗口的名字是 '无标题-记事本'
打印一下这个窗口输入的位置
print(app[chuangkou].print_control_identifiers())
结果
Control Identifiers:
Notepad- '无标题 - 记事本'(L473, T291, R1267, B688)
['Notepad', '无标题 - 记事本', '无标题 - 记事本Notepad']
child_window(title="无标题 - 记事本", class_name="Notepad")|
| Edit - ''(L481, T341, R1259, B658)| ['Edit', '无标题 - 记事本Edit']| child_window(class_name="Edit")|
| StatusBar - ''(L481, T658, R1259, B680)| ['StatusBar 第 1 行,第 1 列', 'StatusBar', '无标题 - 记事本StatusBar']| child_window(class_name="msctls_statusbar32")
4.写一个试试:
from pywinauto importapplication
app= application.Application().start('notepad.exe')
chuangkou= '无标题-记事本'
#print(app[chuangkou].print