Jump to content

Detect when a window X is clicked


 Share

Recommended Posts

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()?

Link to comment
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..)

Link to comment
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.

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
Link to comment
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..
Link to comment
Share on other sites

  • Moderators

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=

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.

Link to comment
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.

Link to comment
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? :)

Link to comment
Share on other sites

  • Moderators

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.

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.

Link to comment
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". :)

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