Forum Discussion

ibeard's avatar
ibeard
Occasional Contributor
9 years ago

Call Windows Form function based on string

This may seem strange, but I am trying to create a python script interface to use with my Keyword Tests. To do this I need to be able to pass in the grid control of any screen within our product. The...
  • HKosova's avatar
    9 years ago

    Hi Ian,

     

    It sounds like you need aqObject.CallMethod:

    aqObject.CallMethod(obj, "methodname", param1, param2, ...)
  • Silmaril's avatar
    9 years ago

    You can use getattr built-in function.

    def main():
      obj = Sys.Process("notepad", 2).Window("Notepad", "Untitled - Notepad", 1).Window("Edit", "", 1)
      callClickMethod(obj, True, -1, -1)
      callClickMethod(obj, False, -1, -1)
    
    def callClickMethod(obj, dbl, x, y):
      getattr(obj, "DblClick" if dbl else "Click")(x, y)