End Windows application (but not simply terminating the process)
I would like to end a certain Windows application gracefully, without using a mouse or keyboard shortcuts. I also don't want to simply end the application's process. (Hence, "gracefully".)
In other words, I would like to invoke the application's own "exit procedure". How do I do this?I don't mind getting down and dirty with code and dubious hacks, I just have no idea where to start… Using AutoHotkey to simulate the key presses required to end the开发者_如何学Python application is not good enough for me. :P
Windows Task Manager uses the EndTask function for this: EndTask Function. This function first sends nice WM_CLOSE messages.
Find the taskbar windows owned by the process (there's usually only one) and send them WM_CLOSE messages.
精彩评论