The WinClose function of AutoIt is used to close windows, allowing them enough time to close, and to show potential dialogs, which users may want to respond to.
When WinClose is used on a window, it sends a close message to the window. How the window reacts depends on the program. Some programs might ask the user to save unsaved data for example.
If multiple windows match criteria of the title parameter, the one that was most recently active will be closed.
If you want to forcibly close a window, you can use the WinKill function instead.
|Title||The title of the window.||Required|
|Text||The text of the window to read.||Optional|
; Attempt to run notepad Run("notepad.exe") ; Wait 10 seconds for the window to appear WinWait("[CLASS:Notepad]", "", 10) ; Wait a couple of seconds before running WinClose Sleep(2000) ; Now close the window using the saved window handle WinClose("[CLASS:Notepad]")