当前环境:Win10 + Python3.7 + pywinauto==0.6.8,selenium==3.14.1
示例代码
from pywinauto import Desktop
import os
app = Desktop()
dialog = app['打开']
dialog['Edit'].set_edit_text(os.getcwd() + '.\\example-01.jpg')
dialog['Button'].click()
'''
其他方法:
from pywinauto import application
import os
app = application.Application()
app.connect(title='打开')
# app['Dialog']['Edit1'].type_keys(os.getcwd() + '.\\example-01.jpg')
# app['Dialog']['Edit1'].SetEditText(os.getcwd() + '.\\example-01.jpg')
app['Dialog']['Edit1'].set_edit_text(os.getcwd() + '.\\example-01.jpg')
app['Dialog']['Button1'].click()
'''
参考:
https://mp.weixin.qq.com/s?__biz=MzU1NzgyNDI3NQ==&mid=2247484679&idx=1&sn=a340747f16f0c5697764ede7f448a63d&chksm=fc2ea57bcb592c6da51fd3f186a557ac29994bb78b919c618f17ae10fbbdfb16d7c8230e427a&mpshare=1&scene=1&srcid=1216DMzWHdhTgZYFFbVGZHsW&sharer_shareinfo=c65396678acf6d09bcf06fc57ed0addd&sharer_shareinfo_first=c65396678acf6d09bcf06fc57ed0addd&exportkey=n_ChQIAhIQduawNpbBAqP4iyR8%2FYTAShLyAQIE97dBBAEAAAAAAM%2FgFUW0vVIAAAAOpnltbLcz9gKNyK89dVj0DOxgVp8EciivdLsqOeEOeDn%2FVPMouyiXKMKo40Fk76NmX8%2B9UecOMBQOLNgS3oM3USy95IGseYWfWmx08Blkzlyllc0Fobk7aCaaipck4W8pJ%2BLJX6rD5iywpWQwG6vffOs6llL8yGnU6e30ZjFrjPV9IILsurSLzrVbglwwjtgTOb1FpTslaJw4PK6nBzF4Qos2x0Zj9%2FSFKiEKhPosme7v7ePriXmNDr7iQFaEOlp4p5f69wL9O1BWV0CY6ovevQu2D9r1iYKzjsn1&acctmode=0&pass_ticket=gc%2Bk84qheb1bQ6ScSF35lH7APcEXiU415dFWdmHHbPZqiETZGvHPyD4ZC2OJMHN7hRX2TdXRrFc16LrLv0llyg%3D%3D&wx_header=0#rd
https://mp.weixin.qq.com/s?__biz=MjM5NTU0MDg0MA==&mid=2651267611&idx=1&sn=c1ae1a4a17b1c63c18dc223d8ba23af3&chksm=bd05781c8a72f10a81cf6239044a6354d9137f8e322dcea9383852f90c89fb3b554eb766eb94&mpshare=1&scene=1&srcid=12164RziUu8kd3yryjnvtZbU&sharer_shareinfo=8f38390e1fc6e5b07aaa3bd8c3e68f07&sharer_shareinfo_first=8f38390e1fc6e5b07aaa3bd8c3e68f07&exportkey=n_ChQIAhIQrwmNtaFAKwU0xpCrjCRctRLyAQIE97dBBAEAAAAAAHDQCsJVPy0AAAAOpnltbLcz9gKNyK89dVj0MmfYFIQO3IjAltC9jzxNXjdYR%2F31Ok%2BvtyLtDB6OaZNw%2BGBsHYRd%2BsXSUrbrXLC1ONnJ%2FPAiluSRe0iQILwcgzD8LboFF%2F8YfhIBFIAVsAYDAJfNzFpstvgOkiXf0PZsuw1p%2Bg3M7N25llXF7VQ21%2FDqePZcYMEc7JXRtEfo1%2BkWgf1VJU%2Bp9SA8EuCaSu1Tbb3CXWb0Fy%2FwCDld8LB9zJ%2FppHyc9dG6uIdBES8AiHoZDHwHkYHGvhpjrlf8ZOpDjH%2BsVwa%2BIFR0ulX2&acctmode=0&pass_ticket=gc%2Bk84qheb1bQ6ScSF35lH7APcEXiU415dFWdmHHbPZoefKqE%2BuBGd4YY3MF66ov5%2FCbx0d5wkGWluKyPGNFrA%3D%3D&wx_header=0#rd
https://www.qiniu.com/qfans/qnso-60569025