【发布时间】:2018-12-04 22:09:15
【问题描述】:
我在屏幕上有一个鼠标位置,例如 (10, 10),我想将该位置转换为控件。我该怎么做?
例子:
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()
pywinauto 是否已经为此提供了内置功能?在this question 上,我发现了如何使用 pywinauto 遍历窗口中的所有控件。所以迭代它,我可以检查是否controls[i].rectancle().top == 10 and controls[i].rectancle().left == 10。
什么是正确的做法?
【问题讨论】:
标签: python python-3.x pywinauto