Search code examples
pythonpywinauto

Not able to access child window using pywinauto


Control identifiers
enter image description here

I am trying to automate the process to decrypt the file using kleopatra application using pywinauto library. I'm able to connect and the access the element from the main window, but not able to get hold of the new window that pops up.

I want to access the new windows element and open a file from that window whose title is "Select One or More Files to Decrypt and/or Verify".

Here is what I'm doing in the code, but getting the error.

import pywinauto
app = pywinauto.application.Application(backend='uia').start(r"C:\Program Files (x86)\Gpg4win\bin\kleopatra.exe").connect(title="kleopatra",timeout=100)

fileMenu = app.kleopatra.child_window(title="File", auto_id="MainWindow#1.file.file", control_type="MenuItem").wrapper_object()

fileMenu.click_input()

# app.kleopatra.print_control_identifiers()

decryptMenu = app.kleopatra.child_window(title="Decrypt/Verify...", auto_id="KXMLGUIClient-KActionCollection.file_decrypt_verify_files", control_type="MenuItem")

decryptMenu.click_input()

selectFileWindow = pywinauto.application.Application(backend='uia').connect(title = "Select One or More Files to Decrypt and/or Verify")


How can I connect to new window?

Error
enter image description here


Solution

  • Try this - selectFileWindow = app.window(title = "Select One or More Files to Decrypt and/or Verify")