Jump to content

WinClose versus ProcessClose


 Share

Go to solution Solved by JLogan3o13,

Recommended Posts

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 by mr-es335
Link to comment
Share on other sites

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 by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

  • Moderators
  • Solution

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.

"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

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!

Link to comment
Share on other sites

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.

When the words fail... music speaks.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...