titlebar = [x for x in window.AccessibleChildren if x.accRole == TitleBar]
minimize = [x for x in titlebar[0].AccessibleChildren if x.Name == 'Minimize']
if len(minimize) != 0:
    mimimize[0].accDoDefaultAction()
Python code to automate desktop activities in windows