Skip to content Skip to sidebar Skip to footer

Windows Gui Automation On Legacy App

I'm trying to automate an old windows app called FacTel5. I've been able to automate the login part but the next form is a bullet-like list whose controls are not showing, neither

Solution 1:

These controls even don't react on keyboard actions. So the only solution is to click by coordinates! But stop! It's unreliable! If it's absolute screen coordinates, yes it is. But we may use relative coordinates (origin is a top-left corner of the control). It can be reliable if control sizes are fixed.

This code works for me on Win10 x64:

from pywinauto.application import Application

app = Application(backend="uia").start(cmd_line=r"C:\Program Files (x86)\Factel5\Factel5.exe")
# this main window spec should work even if the subtitle changes
main_window = app.window(title_re=u'FacTel5 - Telef\u0443nica.*')

controlAcceso = main_window['Control de acceso a FacTel5'].GroupBox
user = controlAcceso.Edit1
user.set_text("userid")
password = controlAcceso.Edit2
password.set_text("password")
controlAcceso.child_window(title="Aceptar", control_type="Button").click()

controlAcceso = main_window['Control de acceso a FacTel5'].child_window(title=u'\u0457Qu\u0439 desea hacer?')
# controlAcceso = main_window['Control de acceso a FacTel5'][u'\u0457Qu\u0439 desea hacer?'] # TODO: need a bug fix
rect = controlAcceso.rectangle()
item1 = (rect.width() / 2, int(float(rect.height() * 2.0) / 11.5))
item2 = (rect.width() / 2, int(float(rect.height() * 3.0) / 11.5))
item3 = (rect.width() / 2, int(float(rect.height() * 4.0) / 11.5))
item4 = (rect.width() / 2, int(float(rect.height() * 5.0) / 11.5))
item5 = (rect.width() / 2, int(float(rect.height() * 6.0) / 11.5))

item6 = (rect.width() / 2, int(float(rect.height() * 8.5) / 11.5))
item7 = (rect.width() / 2, int(float(rect.height() * 9.0) / 11.5))
item8_exit = (rect.width() / 2, int(float(rect.height() * 10.0) / 11.5))

# uncomment move_mouse and comment click_input to see where the click happens# controlAcceso.move_mouse_input(coords=item1, absolute=False)
controlAcceso.click_input(coords=item1, absolute=False)

main_window.menu_select(u'Facturaciones->Gestión de facturaciones')

Post a Comment for "Windows Gui Automation On Legacy App"