Getting x/y position on desktop applications for UI automation

Question:

Within other applications on a Windows desktop I am wanting to get the x/y coordinates of certain things within the application. I have seen several freeware utilities that say they do this and have come across several scripts that say they do this as well. The application, I am trying to do this on has no API so I am wanting to automated the same office UI tasks every day to save me alot of time.

Someone with knowledge in this domain let me know what is the best way or the best way they know. Thank you

Asked By: Red

||

Answers:

you can see this api, it can solve your questions, not only desktop application, but also web applicatin, besides position, it can also return size of the control.
https://www.clicknium.com/documents/api/python/uielement/get_property

Answered By: justin

calling this function works:

def get_the_pos_of_the_mouse_Cursor():
    try:
        while True:
            x, y = pyautogui.position()
            positionStr = 'X: ' + str(x).rjust(4) + ' Y: ' + str(y).rjust(4)
            print(positionStr, end='')
            print('b' * len(positionStr), end='', flush=True)
    except KeyboardInterrupt:
    print('n')
Answered By: Red
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.