I have the following automation program, that sends the email to myself with a specific link added:
import win32com.client as win32
import easygui
import tkinter as to
from tkinter import filedialog
import pywinauto
import pywinauto.controls
from pywinauto.application import Application
### easygui commands asking user for the inputs
fieldNames_text= ['','']
fieldNames= ['Subject','Link']
INPUT = easygui.multenterbox('Please fill in', 'FIN and PASSWORD', fieldNames, fieldNames_text)
answer = easygui.ynbox('Any attachement?', 'Attachement', ('Yes', 'No'))
### outlook handling
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = 'name.surname@.com'
mail.Subject = INPUT[0]
mail.Body = INPUT[1]
### attachment addition
if answer == True:
root = tk.Tk()
root.withdraw()
file_path = filedialog.askopenfilename()
mail.Attachments.Add(file_path)
else:
pass
### mail sending
mail.Send()
time.sleep(5)
### dealing with pop up window
app = Application(backend = 'uia').connect(title='Microsoft Azure Information Protection')
dlg = app.window(title_re="Microsoft Azure Information Protection")
dlg.child_window(auto_id='General').click_input()
dlg.child_window(auto_id='OkButton').click_input()
The last 4 lines of the code should be dealing with the window that is activated when mail is sent. This is how the window looks like:

However, as the window is pooped up, those lines of code are not executed, but if I try to open the new console and execute those lines there, the window will respond accordingly. I thought that it could because of the window visibility lag, therefore time.sleep(5) command, but nothing happens...