| View previous topic :: View next topic |
| Author |
Message |
Kellianjaxon
Joined: 04 Jan 2008 Posts: 39
|
Posted: Fri Feb 22, 2008 1:23 am Post subject: Retrieving WM_COMMAND parameters from a 3rd party app |
|
|
I'm pretty sure what I'm going to ask can't be easily carried out but I just need someone experienced to tell me to stop dreaming about it
I have a 3rd party application window with a special slider control, the classname of which can be retrieved. A part of the slider control is a small area that shows numeric value indicating the current position of the slider. That value is what I'd want to monitor.
By following the Message Tutorial I found the right place to look for. Winspector Spy shows three different parameters and their values for WM_COMMAND:
Code: X
Control ID: Y
Control HWND: 0xZZZZZZZZ
The correct value is right there in the field 'Code:' . Control ID seems to be constantly zero.
Unfortunately I have absolutely no idea about how to get the value. Can this be done with AHK using advanced methods, maybe dllcalls? |
|
| Back to top |
|
 |
dncarac
Joined: 31 Aug 2006 Posts: 64
|
Posted: Fri Feb 22, 2008 10:25 pm Post subject: |
|
|
You can intercept the WM_COMMAND message associated with a control within your own AHK program with OnMessage. OnMessage associates a function with a message. The function can have up to four parameters, which include parameters associated with the message. When a message is received, that function is called with the parameters filled in by Windows. The function can test the value of those parameters and perform appropriately. I've used it to detect when an edit box loses focus. I wrote this post on it: http://www.autohotkey.com/forum/viewtopic.php?t=28520&
If you can get it to work with messages associated with outside programs, some of the parameters of the function contain the information you want. I did research on the Microsoft MSDN site and this site has numeric values for the codes: http://manoftoday.wordpress.com/2006/10/23/windows-msg-code-ref-for-autohotkey/
On the other hand, if you have the windows handle for the control, can't you use ControlGet or ControlGetText or one of those to get the value?
DNC |
|
| Back to top |
|
 |
Kellianjaxon
Joined: 04 Jan 2008 Posts: 39
|
Posted: Sat Feb 23, 2008 2:15 am Post subject: |
|
|
| dncarac wrote: | You can intercept the WM_COMMAND message associated with a control within your own AHK program with OnMessage.
--
If you can get it to work with messages associated with outside programs, some of the parameters of the function contain the information you want. |
Yes, that one I knew already. The problem with OnMessage is what you already mentioned in your post - i.e., it's solely meant for monitoring messages the script itself receives. I don't think there's a way to have it monitor message traffic within a 3rd party application.
| dncarac wrote: |
On the other hand, if you have the windows handle for the control, can't you use ControlGet or ControlGetText or one of those to get the value? |
Unfortunately, even though the value is clearly visible to human eye, it's not included in the control's text. |
|
| Back to top |
|
 |
dncarac
Joined: 31 Aug 2006 Posts: 64
|
Posted: Sat Feb 23, 2008 4:13 am Post subject: |
|
|
Bummer. If you do find out how to do this, would you please post it?
DNC |
|
| Back to top |
|
 |
Kellianjaxon
Joined: 04 Jan 2008 Posts: 39
|
Posted: Sun Feb 24, 2008 2:10 am Post subject: |
|
|
| dncarac wrote: | | Bummer. If you do find out how to do this, would you please post it? |
Sure. I'm not expecting a simple solution though. |
|
| Back to top |
|
 |
Kellianjaxon
Joined: 04 Jan 2008 Posts: 39
|
Posted: Sun Mar 02, 2008 3:53 pm Post subject: |
|
|
There was lots of information on the subject on MSDN website. After careful examination, I believe you'd need to set up a hook to monitor system message traffic.
Unfortunately, the only way for the hook to work with threads other than those owned by the calling application, is to have the hook in an external dll file. Even if the dll wouldn't need to be complex to accomplish sole WM_COMMAND message monitoring, building one seems to be way beyond abilities for someone like me who's barely touched C / C++ / whatever AHK would be compatible with.
I don't even know if the dll could be built without appropriate commercial software, any of which I don't happen to possess. |
|
| Back to top |
|
 |
dncarac
Joined: 31 Aug 2006 Posts: 64
|
Posted: Mon Mar 03, 2008 12:52 am Post subject: |
|
|
Interesting. I have a copy of the Microsoft C# visual studio, but haven't had a project worth investing the time to learn it. On the other hand, one of the things I know can be done with is is writing a DLL. It's huge but free. Maybe C# is the way to go.
DNC |
|
| Back to top |
|
 |
Kellianjaxon
Joined: 04 Jan 2008 Posts: 39
|
Posted: Mon Mar 03, 2008 6:07 am Post subject: |
|
|
| dncarac wrote: | | Maybe C# is the way to go. |
Well, you know...there may be one big but. From what I understand of Uncle John's last message in another topic, there's an incompatibility issue involved. I've got no idea about the concepts of "managed" and "non-managed" but apparently Autohotkey is based on non-managed stuff. If C# has this non-managed feature, building a valid dll for AHK use might not be overwhelmingly difficult. |
|
| Back to top |
|
 |
dncarac
Joined: 31 Aug 2006 Posts: 64
|
Posted: Mon Mar 03, 2008 6:57 pm Post subject: |
|
|
I did a little surfing this morning. I reviewed the thread about managed code. Then I went out to look for a free C/C++ IDE/compiler. I found one called Dev-C++. I downloaded it, and created a new project from their DLL template. I named it HelloWorld and without making any changes, I compiled it into a DLL (13.6k ??!!). I then wrote a two line AHK program to call it and it worked like a champ. If you don't count the time I took to surf around looking for free C/C++ IDEs and looking over suggestions and reviews, the total time was under 15 minutes.
| Code: | DLLCall("HelloWorld.dll\HelloWorld")
ExitApp
|
Perhaps this combination is what you need (if so, make sure you get the "full" version with the IDE AND the compiler).
DNC |
|
| Back to top |
|
 |
Kellianjaxon
Joined: 04 Jan 2008 Posts: 39
|
Posted: Wed Mar 05, 2008 1:38 am Post subject: |
|
|
After trying a few things out and searching for information I got to say that learning a fair amount of a new language in order to achieve - in my case - a minor additional feature doesn't pay off enough to motivate going through all the hassle.
I may get back to this issue later if I happen to come across an easily-understandable C/C++ tutorial that covers everything I need to know to build a hooking DLL. Until then, case closed for me. |
|
| Back to top |
|
 |
|