2012-02-29 66 views
0

如何使用pyWinAuto訪問TDBNavigator中的按鈕?如何使用pyWinAuto訪問TDBNavigator中的按鈕(使用Delphi編譯的exe)

當id調用方法print_control_identifiers我無法在DBNavigator中找到按鈕。 這裏是我的代碼:dbNavigator.print_control_identifiers的

import time 

try: 
    from pywinauto import application 
except ImportError: 
    import os.path 
    pywinauto_path = os.path.abspath(__file__) 
    pywinauto_path = os.path.split(os.path.split(pywinauto_path)[0])[0] 
    import sys 
    sys.path.append(pywinauto_path) 
    from pywinauto import application 

from pywinauto import tests 
from pywinauto.findbestmatch import MatchError 
from pywinauto import findwindows 
from pywinauto import WindowAmbiguousError 
from pywinauto.controls import WrapHandle 

from pywinauto.timings import Timings 
Timings.Fast() 

app = application.Application() 
app.connect_(path = "D:\SharedProjects\Projects\pyWinAuto\PYWINAUTO.exe") 
pwin = app.MAIN 
pwin.MenuSelect("Transaksi->Form 2") 


frmDua = app['Form Dua'] 
frmDua.print_control_identifiers() 

dbNavigator = frmDua['TDBNavigator'] 
dbNavigator.print_control_identifiers() 

結果()爲:

Control Identifiers: 
TDBNavigator - '' (L673, T285, R1335, B310) 
'3' 'TDBNavigator' 

沒有按鈕TDBNavigator。那麼,如何才能獲得btnFirst,btnPrev,btnInsert等

回答

0

是,Finaly我發現它

dbNavigator = frmDua['TDBNavigator'] 
dbNavigator.SetFocus() 
SendKeys.SendKeys("""{LEFT 10}""") #Move Cursor To Most LeftButton 
SendKeys.SendKeys("""{RIGHT 4}""") #Move Cursor To InsertButton 
SendKeys.SendKeys("""{SPACE}""") #Perform Click On Insert Button 
相關問題