2010-06-14 46 views
1

我試圖使用Pywinauto自動安裝應用程序。在安裝過程中,最後一個窗口在少數情況下顯示一些警告或錯誤消息,隨後系統開始重新開始。我的目標是捕獲可能的警告消息如何將窗口的控件標識符打印到Pywinauto中的文檔中

app.top_window_()._ctrl_identifiers() 
np.Notepad.Edit.TypeKeys(a,with_spaces=True, with_tabs=True, with_newlines=True) 

這是返回一個包含屏幕所有消息的列表。 第二行就是我想打印在記事本的列表對象,但它拋出一些例外

Traceback (most recent call last): 
    File "<pyshell#37>", line 1, in <module> 
    np.Notepad.Edit.TypeKeys(a,with_spaces=True, with_tabs=True, with_newlines=True) 
    File "C:\Python26\pywinauto\controls\HwndWrapper.py", line 950, in TypeKeys 
    turn_off_numlock) 
    File "C:\Python26\pywinauto\SendKeysCtypes.py", line 629, in SendKeys 
    keys = parse_keys(keys, with_spaces, with_tabs, with_newlines) 
    File "C:\Python26\pywinauto\SendKeysCtypes.py", line 538, in parse_keys 
    c = string[index] 
KeyError: 0 

任何人都可以讓我知道如何做到這一點,或者如果有在此可以處理其他的方式舉個例子?

回答

0

重新格式化::

代碼

app.top_window_()._ctrl_identifiers() # did you mean print_control_identifiers() ? 
np.Notepad.Edit.TypeKeys(a,with_spaces=True, with_tabs=True, with_newlines=True) 

回溯

Traceback (most recent call last): 
File "", line 1, in 
    np.Notepad.Edit.TypeKeys(a,with_spaces=True, with_tabs=True, with_newlines=True) 
File "C:\Python26\pywinauto\controls\HwndWrapper.py", line 950, in TypeKeys 
    turn_off_numlock) 
File "C:\Python26\pywinauto\SendKeysCtypes.py", line 629, in SendKeys 
    keys = parse_keys(keys, with_spaces, with_tabs, with_newlines) 
File "C:\Python26\pywinauto\SendKeysCtypes.py", line 538, in parse_keys 
    c = string[index] KeyError: 0 

你不解釋什麼a包含二號線,但它會出現在你傳遞一個字典和不是一個字符串。 SendKeys()需要一個字符串。

希望可以幫到

相關問題