1
對於下面的代碼,我檢查窗口是否存在以及是否可見。大小寫是Exists返回true(但窗口隱藏)。所以我把另一個檢查is_visible。但是is_visible是拋出異常而不是返回真/假pywinauto is_visible拋出異常,而不是返回true/false值
dlg = app.window_(title_re = "Buy Order Entry.*")
if(dlg.Exists(1)):
#Code enters here but window is hidden
visible = app.window_(title_re = "Buy Order Entry.*").is_visible()
輸出:
Traceback (most recent call last):
File "autoscript.py", line 924, in <module>
visible = app.window_(title_re = "Buy Order Entry.*").is_visible()
File "C:\Python27\lib\site-packages\pywinauto\application.py", line 357, in __getattribute__
ctrls = self.__resolve_control(self.criteria)
File "C:\Python27\lib\site-packages\pywinauto\application.py", line 239, in __resolve_control
raise e.original_exception
pywinauto.findwindows.ElementNotFoundError: {'process': 2164, 'title_re': 'Buy Order Entry.*', 'backend': u'win32'}
File "C:\Python27\lib\site-packages\pywinauto\application.py", line 239, in __resolve_control
raise e.original_exception
pywinauto.findwindows.ElementNotFoundError: {'process': 2164, 'title_re': 'Buy Order Entry.*', 'backend': u'win32'}
我怎樣才能解決這個問題?與窗口標題的正則表達式一起使用時,is_visible是否存在問題?
是的,目前使用該解決方法。謝謝。 –