When you need to detect and close a specific window, you can do using AddAutomationEventHandler method in the namespace System.Windows.Automation. Set Hook line 4, set identifier for window open event which want to detect. line 7, set event handler Set Event Handler line 8, compare name of element with the name to find. line 15, print the contents of the window line 22, find the "No" button, it's name has a character "N". line 24~25, push the button.
A log of my programming study. Includes Godot Engine, Godot Rust, Rust, etc.