Hallo,
ich würde es mit AUTOIT machen. AutoIt v3 - Automate and Script Windows Tasks - For Free!
hier der code:
$WindowTitle ="Fenster Name"
$WindowText = "Text im Fenster"
WinWait($WindowTitle, $WindowText)
WinClose($WindowTitle, $WindowText)
oder
ControlClick($WindowTitle, $WindowText, "Button1")