4

I recently started using pywinauto. I am trying to fetch the title of the pop-up window.

FYI Application background is UIA.

enter image description here

In the above picture, the title of the pop-up window is "Open Media". Is there any way to extract/read this title using pywinauto.

So I am curious that is it possible to find the title of the pop-up window using pywinauto.

Nawaa
  • 87
  • 2
  • 10
  • This isn't a question about pywinauto. This is a question about VLC. It totally depends on VLC's implementation whether you can observe a window's title. – IInspectable Jan 29 '21 at 13:41
  • I gave an example for better clarity. Irrespective of any window application, I want to extract the title of the popup window. – Nawaa Jan 29 '21 at 15:24
  • This isn't guaranteed to work. It relies on the target application to either implement the required UIA interfaces, or at least not break default system implementations. Neither one can be relied upon. While UIA is your best option, you're going to have to be prepared to see it fail for any given target application. – IInspectable Jan 29 '21 at 15:28

1 Answers1

4

You can have the title of the popup window with the following Pywinauto code:

desktop = pywinauto.Desktop(backend="uia")
window = desktop.windows(title="VLC media player", control_type="Window")[0]
wrapper_list = window.descendants(control_type="Window")
for wrapper in wrapper_list:
    print(wrapper.window_text())

The result is: 'Open Media'

You can find it with an inspect tool like "Inspect.exe". You can easily find it with "Pywinauto recorder"

With "Pywinauto recorder" if you hover the pop-up window with the mouse cursor and press CTRL+SHIFT+F it copies the following Python code into the clipboard:

with UIPath(u"VLC media player||Window"):
    wrapper = find(u"Open Media||Window")

Then if you add the next line, you will have the same result as with the pure Pywinauto code above.

print(wrapper.window_text())

Finally you have:

with UIPath(u"VLC media player||Window"):
    window = find()
wrapper_list = window.descendants(control_type="Window")
for wrapper in wrapper_list:
    print(wrapper.window_text())
David Pratmarty
  • 596
  • 1
  • 4
  • 19