Reputation: 161
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
Upvotes: 1
Views: 1066
Reputation: 161
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')
Upvotes: 0
Reputation: 197
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
Upvotes: 1