如何使用pyWinAuto访问TAB Navigator中的按钮(使用Delphi构建的exe)

时间:2012-02-29 01:26:38

标签: python delphi pywinauto

如何使用pyWinAuto在TDBNavigator中访问按钮?

当id调用方法print_control_identifiers时,我无法在DBNavigator中找到按钮。 这是我的代码:

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()

dbNavigator.print_control_identifiers()的结果是:

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

TDBNavigator中没有按钮。那么,我如何访问btnFirst,btnPrev,btnInsert等

1 个答案:

答案 0 :(得分:0)

是的,最终我找到了它

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