I have a mouse position on the screen, for example (10, 10) and I want to translate that posistion to a control. How can I do that?
Example:
from pywinauto.application import Application
app = Application((backend="uia").start("notepad.exe")
dlg = app.top_window()
hardcoded_file_button_rec = dlg.File.rectangle() #<RECT L10, T10, R40, B40>
given_mouse_position = (10, 10)
found_file_button = search_by_position(app, given_mouse_position)
assert hardcoded_file_button_rec == found_file_button.rectangle()
Does pywinauto already has built-in function for that? On this question I found how to iterate over all controls in a window using pywinauto. So iterating over it, I can check if controls[i].rectancle().top == 10 and controls[i].rectancle().left == 10
.
What is the right thing to do?