AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help Advanced! Hook WM_COMMAND with JGRs Hook.dll?

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Slaya
Guest





PostPosted: Thu Jul 19, 2007 8:14 pm    Post subject: Help Advanced! Hook WM_COMMAND with JGRs Hook.dll? Reply with quote

Since the OnMesage() AHK function only monitors messages send to an
AHK script, i searched the forum for a "workaround" and found this thread. http://www.autohotkey.com/forum/topic19367.html+message AFAI understand JGR wrote a global Hook.dll that allows to monitor system near messages.

My understanding of such things is limited, i'm a it technican not a coder Wink but i need to monitor WM_COMMAND messages from a 3party app, so better ask a coder for this.

Sean, majkinetor, JGR could you look into this please. Is it possible to hook the message to get the control ID and HWND of the sending window?

If so could you provide an example please?

Thank you in advance

~Slaya
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Thu Jul 19, 2007 8:31 pm    Post subject: Reply with quote

I suggest you to bump the orginal topic by posting a link to this post. Smile
Back to top
View user's profile Send private message Send e-mail
JGR



Joined: 15 Jun 2006
Posts: 59
Location: Oriel College

PostPosted: Fri Jul 20, 2007 10:44 pm    Post subject: Reply with quote

Slaya:

There are several ways which you could go about this.

SetWinEventHook could be used, but this would probably be tricky to determine the WM_COMMAND parameter, and might have mixed reliability (ie. buttons versus menus, etc.)
However if you can just get away with monitoring button clicks, etc. by EVENT_OBJECT_INVOKED, then this requires no dlls, and has minimal performance/stability issues.

A message hook using the hook.dll could be used, but this will likely cause noticeable performance issues.

I seem to remember that there is a get message hook as well? But I am not sure whether it would be suitable...

You could also inject a dll into the process and sub(super?)class the window procedure(s), but that would require another specialised dll, this would avoid the performance issues.

If autohotkey integration is not necessary, I would seriously suggest that you use SPY++ or similar.

PS. I would usually do some more basic research before posting, but as I am currently using a machine epic in its antiquity, where even browsing and typing is a trial, and I am tired, I can do without another saga of hangs and page faulting sprees, until I can use the better machine tomorrow... (This is a pentium pro running win98 with 80MB RAM). I've spent half an hour already on this post Neutral
Back to top
View user's profile Send private message Visit poster's website
JGR



Joined: 15 Jun 2006
Posts: 59
Location: Oriel College

PostPosted: Sat Jul 21, 2007 12:06 pm    Post subject: Reply with quote

After some research, it emerges that the only method from the above which could be done using the current dlls, and which would enable you to record WM_COMMAND ids and hwnds is the getmessage hook.
You would need to do a readprocessmemory on the last hook parameter to get the message structure, and all system messages would get funnelled through the autohotkey script.
The performance implications of this are so appalling that I think I'll just write a wndproc subclassing dll instead, and post some code for that in the coming day(s) when it's working...

JGR
Back to top
View user's profile Send private message Visit poster's website
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Sun Jul 22, 2007 4:59 am    Post subject: Reply with quote

JGR wrote:
The performance implications of this are so appalling that I think I'll just write a wndproc subclassing dll instead, and post some code for that in the coming day(s) when it's working...

If you succeed to do it for a generic subclassing, it'll be really a great feature, but to be honest I'm half doubtful about it.
I think it would be a lot simpler to extend the function reghook to accept the (target) ThreadID, so as to hook only that thread.
Back to top
View user's profile Send private message
Slaya
Guest





PostPosted: Sun Jul 22, 2007 6:44 pm    Post subject: Reply with quote

Thank you for looking into this JGR.
Will the new DLL only monitor WM_COMMAND Messages, or will it be more generic e. g. it will detect WM_CLOSE etc too?

~Slaya
Back to top
JGR



Joined: 15 Jun 2006
Posts: 59
Location: Oriel College

PostPosted: Thu Aug 30, 2007 7:03 pm    Post subject: Reply with quote

I have just come back from holiday, and school starts tomorrow, so the chances of this happening soon are so close to zero that it is effectively abandoned until I can find a spare few days, in the upcoming year.

My apologies.

JGR
Back to top
View user's profile Send private message Visit poster's website
ando
Guest





PostPosted: Fri Jun 11, 2010 8:41 pm    Post subject: Reply with quote

I am looking for a way to hook all wm_command messages to get the IDs for buttons, icon and so on too. JGR are you still busy or is it possible to show a way to do this?
Back to top
jaco0646



Joined: 07 Oct 2006
Posts: 3113
Location: MN, USA

PostPosted: Sat Jun 12, 2010 6:55 am    Post subject: Reply with quote

ando wrote:
are you still busy
Since 2007? That would be busy indeed.
Back to top
View user's profile Send private message Visit poster's website
JGR



Joined: 15 Jun 2006
Posts: 59
Location: Oriel College

PostPosted: Sat Jul 17, 2010 8:15 am    Post subject: Reply with quote

Edit:
Much of that was wrong, rewriting post again...

It is perfectly possible to capture all message traffic using a WH_GETMESSAGE or perhaps WH_CALLWNDPROC SetWindowsHookEx via that hook dll, however this is clunky to implement and has *awful* performance implications.
The dll is most useful for low traffic, specific hooks like CBT.

Don't hold your breath on someone writing a generic subclassing dll.

I still maintain that you're better off using something like spy++, unless you actually need to automate the process...
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group