python pywinauto 自动化使用

<code>from pywinauto.application import Application
# 对于Windows中自带应用程序,直接执行,对于外部应用应输入完整路径
app = Application(backend="uia").start('notepad.exe')

#描述Notepad.exe进程中的窗口
dlg_spec = app.UntitledNotepad
#等待窗口真正打开
actionable_dlg = dlg_spec.wait('visible')/<code>
<code>from subprocess import Popen
from pywinauto import Desktop

Popen('calc.exe', shell=True)
dlg = Desktop(backend="uia").Calculator
dlg.wait('visible')/<code>
<code>from pywinauto.application import Application
import time

app = Application().start('notepad.exe')
time.sleep(1)
app[' 无标题 - 记事本 '].menu_select("编辑(&E) -> 替换(&R)..")
time.sleep(1)
app['替换'].取消.click()

# 没有with_spaces 参数空格将不会被键入。请参阅SendKeys的这个方法的文档,因为它是SendKeys周围的薄包装。
app[' 无标题 - 记事本 '].Edit.type_keys("Hi from Python interactive prompt %s" % str(dir()), with_spaces = True)

app[' 无标题 - 记事本 '].menu_select('文件(&F) -> 退出(&X)')

# 在这时候不清楚“不保存”的按钮名就对app['记事本'] 使用print_control_identifiers()
app['记事本'].Button2.click()/<code>


python  pywinauto 自动化使用


分享到:


相關文章: