Search code examples
pythondelphipywinauto

How to Acces Button In TDBNavigator (exe build with Delphi) using pyWinAuto


How to Acces Button In TDBNavigator using pyWinAuto ?

when id call method print_control_identifiers i can not find buttons in DBNavigator. here is my Code :

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

result of dbNavigator.print_control_identifiers() are :

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

there is not button in TDBNavigator. So, how can i access btnFirst, btnPrev, btnInsert, etc


Solution

  • Yes , Finaly I Found It

    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