Это то, что я делаю, чтобы определить всплывающие окна.По сути, вы хотите создать диалог (dlg), представляющий окно, которое является родителем всплывающего окна:
app = pywinauto.application.Application(backend="uia")
app.connect(path='gofer.exe')
# Using regular expression to create a dialog of the gofer.exe app
# I am assuming the title will match "*Gofer*" eg: "Gofer the Application"
dlg = app.window(title_re=".*Gofer.*")
# Now I am going to identify the title of the popup window:
dlg.print_ctrl_ids()
# If you did the last step correctly, the output will look something like:
#Control Identifiers:
#Dialog - 'Gofer The Application' (L688, T518, R1065, B1006)
#[u'Dialog', u'Gofer Dialog']
#child_window(title="Warning: ", control_type="Window")
#|
#| Image - '' (L717, T589, R749, B622)
#| [u'', u'0', u'Image1', u'Image0', 'Image', u'1']
#| child_window(auto_id="13057", control_type="Image")
#|
#| Image - '' (L717, T630, R1035, B632)
#| ['Image2', u'2']
#| child_window(auto_id="13095", control_type="Image")
#|
# Now using the same title and control type for the popup that we identified
# We check to see if it exists as follows:
if dlg.child_window(title="Warning:", control_type="Window").exists():
print("Bro, you got a pop-up bro...")
else:
print("No popup Bro...")