Jump to content

Difference between WinKill and ProcessClose at API level


Recommended Posts

Hi all

Currently i have two way to restart my explorer.exe. Either

ProcessClose("explorer.exe")

or

WinKill("[CLASS:Progman]", "")
WinKill("[CLASS:Shell_TrayWnd]", "")

The second script i made after made some reading in here

The question is what does the WinKill & ProcessClose function do at API level? So far i could guest that WinClose function will sending WM_Close. Does the WinKill sending the WM_Quit message and ProcessClose sending the WM_Destroy?

The reason for above question is that currently i'm making a script to close the shell explorer.exe politely based on a msdn blog article. I could make a keyboard simulation to achieve the objective but i wish to do it more geeky way if possible.

Link to comment
Share on other sites

Have you tried looking at the source?

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

I think ProcessClose() calls TerminateProcess() at once while WinKill first tries to kill the window by sending something like WM_CLOSE and if that doesn't work it finds the ID of the process that owns the window and then terminates it with TerminateProcess.

Edited by monoceres

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Thanks monoceres for the info, I tried to find the info myself out of curiosity.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

Thanks monoceres for the info, I tried to find the info myself out of curiosity.

Well I'm only guessing. It seems to be the logical way of doing it.

If you really want to know what happens behind the scenes I suggest you spy on autoit while you do the call. This can be done with the api hooking script in my sig.

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Thank you all for the reply

Have you tried looking at the source?

Autoit is close source, and even there is a source code i don't have the capability to trace and understand the code.

Well I'm only guessing. It seems to be the logical way of doing it.

If you really want to know what happens behind the scenes I suggest you spy on autoit while you do the call. This can be done with the api hooking script in my sig.

That is a great idea but again it is still beyond my capability. It will be great if we know more the details about this functions from the autoit developers. Edited by TokGajah
Link to comment
Share on other sites

After hooking a script that calls WinKill() and monitoring the incoming messages in the target window I came up with the following:

  • AutoIt sends the WM_CLOSE message to the target window.
  • Waits approximately 500 ms for the window to close.
  • If the window still haven't close AutoIt tries to terminate the process by calling the TeriminateProcess() api.
  • Gives up

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

After hooking a script that calls WinKill() and monitoring the incoming messages in the target window I came up with the following:

  • AutoIt sends the WM_CLOSE message to the target window.
  • Waits approximately 500 ms for the window to close.
  • If the window still haven't close AutoIt tries to terminate the process by calling the TeriminateProcess() api.
  • Gives up
Isn't this guy great?

edit:

monoceres, you should do more stuff like this

Edited by trancexx

♡♡♡

.

eMyvnE

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...