clo [window]
The window may reject the request. For example, the window may be hung, or display a "Save?" message box. QM ignores that, ie does not wait and does not generate error if the window remains open.
Error if the window does not exist. Use err to continue the macro.
The speed depends on spe.
If the window belongs to other program or thread, clo sends WM_SYSCOMMAND/SC_CLOSE or/and WM_CLOSE message, depending on window type and state. With some windows it may not work well. You can send one of these messages instead of using clo. See examples.
To destroy a window of current thread, you can use clo or DestroyWindow. If used clo, the window will receive WM_CLOSE message. If it is a dialog with Cancel button, it is equal to pressing the Cancel button. If using DestroyWindow, the window will not receive WM_CLOSE. It will receive WM_DESTROY in either case. Don't use DestroyWindow to destroy modal dialogs.
See also: shutdown, ShutDownProcess, CloseWindowsOf.
clo "Notepad" ;;close "Notepad" window clo ;;close active window clo win("Notepad" "Notepad"); err ;;close "Notepad"; don't generate error if it does not exist post message int h=win("Notepad" "Notepad") PostMessage h WM_SYSCOMMAND SC_CLOSE 0 or PostMessage h WM_CLOSE 0 0