Reputation: 1234
I have the following code:
from pywinauto import Desktop
from pyautogui import position
while True:
desktop = Desktop(backend="uia")
control = desktop.from_point(*position())
control.draw_outline()
So on every code loop pywinauto draws a green rectangle on the control of the current mouse position. Like this:
But, exclusively, on the CMD application, the from_point
function does not find the status bar and the scroll bar. It only finds the Text Area.
I think it is something related to the CMD application, probably it draws its text area control in front of all the others controls. So I want to know if it possible to overcome this sitution, using the functions top_from_point
and/or parent
, perhaps. It is worth mentioning that I have not found any other application with the same behavior, but it may be that some other application also has this problem.
Upvotes: 2
Views: 257
Reputation: 716
This behavior can be reproduced with 'Inspect.exe': If you hover over Windows CMD with the mouse cursor, it only finds the "Text Area" control. To find the other controls, you must click on the tree in the inspect GUI.
With Pywinauto, it's the same: If you hover over Windows CMD with the mouse cursor, it only finds the "Text Area" control. To find the other controls, you must execute the following code: print(control.top_level_parent().descendants())
The implementation of from_point is in uia_element_info.py:
@classmethod
def from_point(cls, x, y):
return cls(IUIA().iuia.ElementFromPoint(tagPOINT(x, y)))
It is using MS UI Automation API function from UIAutomationCore.dll
So I assume it could be an issue of iuia.ElementFromPoint.
Upvotes: 2