Sign in to follow this  
Followers 0
Swift

Detect when a window X is clicked

28 posts in this topic

I have a problem with IE7, it doesn't like to close when I hit the X, it slowly closes, like after a minute it will close. (No, im not changing browsers) I cannot use If ProcessExists() because the process is still there while it's taking its time closing...Is there something I can use like get the handle and stuff, and wait for the X to be hit, and then if it's hit ProcessClose()?

Share this post


Link to post
Share on other sites



Did you actually try to run ProcessClose() on the browser to see if it was any faster?

Share this post


Link to post
Share on other sites

Did you actually try to run ProcessClose() on the browser to see if it was any faster?

Yeah, processClose() closed it instantly, pressing the x it takes about 1 minute...

Share this post


Link to post
Share on other sites

Yeah, processClose() closed it instantly, pressing the x it takes about 1 minute...

This sounds like maybe you have a large cache that may be set to empty on exit.

Share this post


Link to post
Share on other sites

This sounds like maybe you have a large cache that may be set to empty on exit.

I have CCleaner run on startup everyday.

Share this post


Link to post
Share on other sites

You could hook the window messages and wait for WM_CLOSE.

Share this post


Link to post
Share on other sites

Hmm..Now with no add-ons whatsoever, it takes about 10 seconds...I think im better off just doing what RichardRobertson said..

How exactly would I 'hook' the window messages?

Share this post


Link to post
Share on other sites

I'm afraid I don't know how to perform hooks. I'm sure that if you search Microsoft long enough, you'll find it.

Share this post


Link to post
Share on other sites

I'm afraid I don't know how to perform hooks. I'm sure that if you search Microsoft long enough, you'll find it.

Hmm, ok thanks!

Share this post


Link to post
Share on other sites

From my experience you can't hook into other windows "Window Procedure"(kind of what GUIGetMsg does for AutoIt created GUIs) without a DLL file, as it requires the Hooks Callback procedure to be in a DLL(so it can get loaded by the external application..)

Share this post


Link to post
Share on other sites

I know it's possible because Spy++ (part of the Visual Studio package) can read the messages. I didn't think it would require a dll unless you are referring to AutoIt's capabilities.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

I know it's possible because Spy++ (part of the Visual Studio package) can read the messages. I didn't think it would require a dll unless you are referring to AutoIt's capabilities.

hMod

[in] Handle to the DLL containing the hook procedure pointed to by the lpfn parameter. The hMod parameter must be set to NULL if the dwThreadId parameter specifies a thread created by the current process and if the hook procedure is within the code associated with the current process.

Source: http://msdn2.microsoft.com/en-us/library/m...990(VS.85).aspx

The only hooks that you can make that doesn't require a dll(as far as my smurfing has proved me that is) is the low level keyboard and mouse hooks, saddly. :/

Edit:

btw. if you want a good(if not better) alternative to Spy++, check out Winspector: http://www.windows-spy.com/

Edited by FreeFry

Share this post


Link to post
Share on other sites

That's really stupid. Just goes to show why Microsoft programs are resource hogs.

And no, I don't need Spy++ to begin with. I just know it can intercept the messages.

Share this post


Link to post
Share on other sites

That's really stupid. Just goes to show why Microsoft programs are resource hogs.

And no, I don't need Spy++ to begin with. I just know it can intercept the messages.

I think im just going to have a hotkey...its getting way too deep..

Share this post


Link to post
Share on other sites

Source: http://msdn2.microsoft.com/en-us/library/m...990(VS.85).aspx

The only hooks that you can make that doesn't require a dll(as far as my smurfing has proved me that is) is the low level keyboard and mouse hooks, saddly. :/

Edit:

btw. if you want a good(if not better) alternative to Spy++, check out Winspector: http://www.windows-spy.com/

The link you provided there (MSDN2), I would personnally look at WH_GETMESSAGE, and use a method that you used before: http://www.autoitscript.com/forum/index.ph...st&p=493478 (Don't know how you expect to do anything without a native windows dll/api call anyway)

Or even look Siao's (Windowdestroyed) http://www.autoitscript.com/forum/index.ph...c=56536&hl=


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

The link you provided there (MSDN2), I would personnally look at WH_GETMESSAGE, and use a method that you used before: http://www.autoitscript.com/forum/index.ph...st&p=493478 (Don't know how you expect to do anything without a native windows dll/api call anyway)

Or even look Siao's (Windowdestroyed) http://www.autoitscript.com/forum/index.ph...c=56536&hl=

Thanks Smoke_N, I'll check those links out.

Share this post


Link to post
Share on other sites

The link you provided there (MSDN2), I would personnally look at WH_GETMESSAGE, and use a method that you used before: http://www.autoitscript.com/forum/index.ph...st&p=493478 (Don't know how you expect to do anything without a native windows dll/api call anyway)

Or even look Siao's (Windowdestroyed) http://www.autoitscript.com/forum/index.ph...c=56536&hl=

Can you make that hook on a application you're not 'owning', without a dll? :)

Share this post


Link to post
Share on other sites

Can you make that hook on a application you're not 'owning', without a dll? :)

What are you talking about? What app are you "owning"? I think you are reading this

SetWindowsHookEx can be used to inject a DLL into another process. A 32-bit DLL cannot be injected into a 64-bit process, and a 64-bit DLL cannot be injected into a 32-bit process. If an application requires the use of hooks in other processes, it is required that a 32-bit application call SetWindowsHookEx to inject a 32-bit DLL into 32-bit processes, and a 64-bit application call SetWindowsHookEx to inject a 64-bit DLL into 64-bit processes. The 32-bit and 64-bit DLLs must have different names.

An error may occur if the hMod parameter is NULL and the dwThreadId parameter is zero or specifies the identifier of a thread created by another process.

Calling the CallNextHookEx function to chain to the next hook procedure is optional, but it is highly recommended; otherwise, other applications that have installed hooks will not receive hook notifications and may behave incorrectly as a result. You should call CallNextHookEx unless you absolutely need to prevent the notification from being seen by other applications.

completely wrong.

Run Siao's code to get a better idea... There's no DLL injecting there, and he doesn't own any app/process other than the one he launched himself.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

What are you talking about? What app are you "owning"? I think you are reading this completely wrong.

Run Siao's code to get a better idea... There's no DLL injecting there, and he doesn't own any app/process other than the one he launched himself.

Oh, I see now. I just glanced at Siaos code, and I just saw GUICreate and assumed he was hooking into his own window. soz

What I meant was because you said you'd look at WH_GETMESSAGE instead, and that was what I where asking, if you can make that hook without a dll on a window that the autoit script doesn't "own". :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0