mr-es335 Posted November 9, 2023 Share Posted November 9, 2023 (edited) Good day, It may appear to be obvious, but is one preferred over the other? For example: #include <MsgBoxConstants.au3> Example1() Example2() Func Example1() Run("C:\RML\SAC\SAC64.exe") Sleep(2000) WinClose("[CLASS:SAC_MAIN]", "") EndFunc ;==>Example1 Func Example2() Sleep(2000) Local $iPID = Run("C:\RML\SAC\SAC64.exe") WinWait("[CLASS:SAC_MAIN]", "", 10) Sleep(2000) ProcessClose($iPID) EndFunc ;==>Example2 The following suggested why one might employ WinClose over ProcessClose - [Link] Edited November 9, 2023 by mr-es335 mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
Andreik Posted November 9, 2023 Share Posted November 9, 2023 (edited) While ProcessClose() close a certain process, WinClose() close a window but it doesn't necessarily means it close the process also. It might be a window among other windows that are associated with a process. If there is a single window associated with a process and by closing the window the process is also closed, this would be my choice as a less brutal way to kill a process. Edited November 9, 2023 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Moderators Solution JLogan3o13 Posted November 9, 2023 Moderators Solution Share Posted November 9, 2023 I think you have answered your own question in the link. ProcessClose is an termination action; just like going into Task Manager and ending the process through the GUI. WinClose sends a close message to a window (similar to clicking the x). It is not so forceful as WinKill or ProcessClose, as you will be prompted if there is data to save. So, as to the "preferred" option, like most questions, it depends on what you're trying to accomplish. mr-es335 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
mr-es335 Posted November 9, 2023 Author Share Posted November 9, 2023 Andreik and JLogan3o13, Firstly, thank you both so very much for your comments...very much appreciated! Secondly, what I am looking for is "a quick exit"...thus I have been employing "ProcessClose". Thirdly, my primary concern is possible application damage or data file damage...though I have not experienced either - at least, thus far I have not! mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
Andreik Posted November 9, 2023 Share Posted November 9, 2023 As JLogan3o13 already said, by closing an application with WinClose() you give the opportunity for the application to process the close message as it wants. The application might have to release resources or maybe to close some files or other things, so it's generally a better way to close a window or by case an entire process. With WinClose() the application will have that chance but ProcessClose() will kill the process as it will be terminated from Task Manager. mr-es335 1 When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now