Windows Hooks

Miscellaneous Forums/General Discussion/Windows Hooks

This stuff looks like it should be simple but like most things it's proving to be a bit of a pig.

Basically I want to set up a hook to monitor another window, I need to know when the window is moved. I have the HWND of the other window and other information.

Can anyone shed any light on this?

http://www.blitzbasic.com/Community/posts.php?topic=53212

see if this helps at all

Do you need to react *immediately* after the window is moved or *as* the window is moving or would it be OK a millisecond or so later (cos I can do that with my framework but not with hooks. It totally works fine btw).

I need hooks as I need to intercept and act on the messages.

Unless your process created the Window, you may find XP won't allow you to do anything of the sort (where as win98 will) as it is an easy way of adding keyboard loggers etc.

If it is your window checkout timer.mod/timer.win32.c for example of hook usage.

Thanks skidracer,

I've got it working now, can monitor messages from parent threads, child threads and remote threads OR all windows on the desktop. Works in XP too!

coolio.


Works in XP too!



I've played around with hooks, though, I never totally got them working properly!

Any chance of having a peek at the source? :)

Dabz

Hi Dabz,

I was actually for a c++ project so it may not be relevant.

And don't assume the window you are hooking is ANSI, check it!
IsWindowUnicode(c.browser_hwnd)


And make sure you remove the hooks or you'll be in a world of crap.

Hiya Indie,

I'm fine with C++, that's what I was using when I was playing with hooks! :)

I really wanted to catch keyboard hooks, basically, I had a client/server application and I needed to hide the server (So no-one would close it down), but use a hook to re-activate the window when it is needed!

Now, before anyone thinks 'He wants keyboard hooks, so he must be going to write a keylogger', I'm not into that sort of coding. It was in fact for an application that that I posted in this thread here:-

http://www.blitzbasic.com/Community/posts.php?topic=55374

Now, since I never really figured out hooks, I can still hide the window, but the only way I could really reactivate the window was sending a message from the client! Which, is a bit of a bugger really! :)

I've rewrote the application and tightened security in it, but using a hook would definitly make me a lot happier with the program!

Dabz

Dabz,

Hooks just re-route the message queue, you still need to manually send the messages onwards to the old WinProc.