Pywinauto练习

from pywinauto.application import Application


app = Application().start("win32calc.exe")
app = Application().connect(title="计算器")
#app["计算器"].print_control_identifiers()

var1=app["计算器"]["1"].Exists
if var1:
print ("1 - if 表达式条件为 true")

#分别点击按钮:1+2=
app["计算器"]["Button5"].click() #按钮1
app["计算器"]["Button23"].click() #按钮+
app["计算器"]["Button11"].click() #按钮2
app["计算器"]["Button28"].click() #按钮=

varname=app["计算器"]["Static4"].Name
print ("varname=",varname)

var2=app["计算器"]["Static4"].texts()
print ("var2=",var2)

#获取1+2的结果
var3=app["计算器"]["Static4"].window_text()
print ("var3=",var3)

#判断加法计算1+2是否正确,注意var3是字符类型
if var3 == '3':
print("计算正确")

app["计算器"]["Static4"].type_keys("111")

#UIA_TextControlTypeId (0xC364)

#edit_box=app.Dialog.Edit.WindowText()




posted @ 2021-04-03 12:54  xxm_2017  阅读(99)  评论(0编辑  收藏  举报