The demo works, but...
How do I adapt this to only catch messages sent from the form in the external app? I have tried (somewhat wishfully) passing the forms hwnd in instead of using findwindowex to no avail....
Printable View
The demo works, but...
How do I adapt this to only catch messages sent from the form in the external app? I have tried (somewhat wishfully) passing the forms hwnd in instead of using findwindowex to no avail....
Hi..
This is a great code. The DLL works good. But it cant get the web applications. Is it possible to get data in web application using this DLL?
Hi,
Very great work! Thanks.
I think that might be why i cannot do what I'm trying to do: I installed a hook and can deal with the message when it occurs. Using CopyMemory I can receive data sent along, but I'd like to *modify* those date, so I need to use CopyMemory again with my modified values.Quote:
Originally Posted by moeur
It "looks like" it to work, as in no crash or anything, but the external app actualy behaves as if I didnot send back any new values :confused:
Could this be the reason why, and if so could anyone help me with how to "subclass" an external app then (would another DLL be required instead of this one??), or am I missing something here/should it work fine with such hooks ?
Thanks for your help!
You might want to look into the following topics:
Using userdefined/non-marshalled messages in external programs by allocating memory in their process space
Inject your code into other processes
More process injection, function redirection
Good Luck
Thanks!
I've done some more reading & testing, but I'm getting more confused than anything else.
Here's what I'm trying to do: add a menuitem to the menu of another app, eg. notepad, but with "complete control" over it.
Adding the menu and getting it just a few API calls, no problem. But I set it ownerdrawn, because I want to actually draw it myself. And my problem is when dealing with the WM_MEASUREITEM, etc messages. I did it on my VB app and it that went well.
So I tried using your great DLL to set up a hook to get the notepad's messages. I did got the message, but as I mentionned in my previous post setting my data on WM_MEASUREITEM seems to be ignored by notepad :S
So I tried a few different ways, like instead of a CopyMemory I used a OpenProcess/VirtualAllocEx/WriteProcessMemory, because I thought that might have been the problem.
Seems not. I got the same results. But it seems that the data are written (according to lpNumOfBytesWritten for WriteProcessMemory), actually both times: even with a single CopyMemory, I think, because if afterwards I do another CopyMemory to get back the data (like the first time, when I got the menuitem's index, etc) the new width/height I set are returned.
I not an expert of all this, but I tried reading different posts/articles/etc but I have no idea what's happening here. To me it looks like the data are written, yet ignored by notepad??
Even more confusing (to me), I did on WM_DRAWITEM draw my menuitem all red, to see if I could actually draw on notepad or not.
And I can, but I'm not drawing where I should be (on menubar) but below it, within the edit area!! The horizontal position is right though, and the vertical space makes me say it looks like the problem is that I'm not draing on notepad's non-client area!! Like I got the "wrong" hDc or something...
Again, I'm not even sure what I just said make sense, but that's all I can see.
Does anyone ever done something like this? Or has an idea of what's the problem/how to fix this?
Thanks.
How would I use this to hook all requests to shell32.dll's SHBrowseForFolder API so that the BrowseForFolder window displays shortcuts to folders (or even all files)?
Does your DLL support WH_CBT?
You may be tired of questions about your post “Subclass External Programs done for you” from Jan 2005. I see that your last post to this thread was just days away from being one year ago. This is probably the best example I have ever seen on line, and is probably the closest to answering my quest. I am desperately seeking a way to read a popup menu (class name "#32768). I can get the handle, I can manipulate it (activate, scroll, select) without a problem. The problem is, I am blind to the text in this type of menu and what I am selecting. I have a post “Read from Popup Menu” looking for something like your dll, ocx. Is it capable of reading this type of menu and or which selection is highlighted? I would be extremely grateful for any help! I have been seeking a solution everywhere and it appears you are my best hope in weeks. I consider myself a reasonably good VB coder but subclassing I just can’t seem to get down.
Hai,,
hook and unhook when mouse move over the windows
i am getting an error (some time).
Runtime Error "5"
Error Setting Dll Filter. 5 (5&h): Access Denied.
Whats wrong ?
part of my code
Code:'monitor the following message(s)
.AddMessage WM_LBUTTONDOWN, "WM_LBUTTONDOWN"
.AddMessage WM_MOUSEMOVE, "WM_MOUSEMOVE"
Some time when the mouse move form one window to another, this error happens.Code:If uMsg = WM_LBUTTONDOWN Or uMsg = WM_MOUSEMOVE Then
uMsg = WM_NULL
End If
but not all the time .
Hello,
First of all, thanks for the great dll.
However, I'm trying to make it run on a Windows Mobile device, with the compact framework 3.5...with no success.. I've managed to modify the VB part but with my limited knowledge in C I was unsuccessful in recompiling the dll for the compact framework. I know that the functions SendMessage and SetWindowsHookEx exist in the CF (even if not documented), so it should be possible to make the project run in CF.
Can someone with VC knowledge help me recompile the dll for the Compact Framework 3.5, please.
How can I hook into a program's file output. Basically I want to intercept what a program is outputing to a file and modify it before it gets there.
Thanks
I just HAD to post to say - AWESOME CODING!!! THANKS MAN!!
*rates*
I actually have another dll which doesn't have any bugs, as there are some bugs in the dll that u have used. But I don't have the code for that dll. I have tried a thousand time to search the code of that dll in the internet but have failed. And also that dll let me capture all kind of messages from the notepad window
Good Day Mr. Moeur,
I am wondering if it is possible to use your dll, or some version of it, to capture the WM_CREATE message and alter the CREATESTRUCT UDT so that the lpCreateParams would contain a pointer to the MDICREATESTRUCT UDT to make an external program an actual child of a VB MDI application.
Hello Moeur,
when you say: To Get the string value pointed to by lParam you can use a function like this: Public Function StrFromPtr(pStr As Long) As String ...
Where can I do the call to this funcion? In the Form or the module...
Thanks
In the hook Demo 2 posted(post 2) here, I'm getting a crash when mousing down over the notepads scrollbar.
http://www.vbforums.com/showpost.php...48&postcount=2
To reproduce:
Add some carriage returns, so that the scrollbar is visible.
Press L Button down to scroll on the scrollbar.
Am I using it wrong, or should that be filtered?
What's the childclassname? And why should it be "Edit" when i hook notepad?
I need to know because when i hook another application with a different Parentcaption i get an error saying i must set handle before setting hook.
Anyone?
I've a new labtop working with windows 7.
The file hookcontrol.ocx seems to be not compatible with version x86 (32bits) or X86(64bits) of regsvr32.exe.
Is it possible to have an updated version of this ocx file or a way to compile myself on my labtop.
Thanks in advance
Try pressing the Windows key+R, then copy and paste:
If this doesn't work, what error message are you getting?Code:c:\windows\syswow64\regsvr32.exe hookcontrol.ocx
@moeur
i need to fill fields of an embedded webbrowser in another app from my app, how can i acheive this with your dll?
thanks
Hi moeur, excellent work.
I tried the .NET version you posted, in VB and C#, but in both cases the events don't fire from the hook. All appears to set up ok, window handle obtained, messages added, etc. An instance of EditHook (clsHook) exists and is visible in watch window. Any ideas if I have missed something? Thanks.
ADDENDUM it works on a Win32-only machine, but not on a Win64 machine when targeted to x86. IDEAS?
I tried the .NET version you posted, in VB and C#, but in both cases the events don't fire from the hook. All appears to set up ok, window handle obtained, messages added, etc. An instance of EditHook (clsHook) exists and is visible in watch window. Any ideas if I have missed something? Thanks.[/QUOTE]
No, I was running in VS2010 in admin mode anyway. It DOES work on a Win32 machine, but not a Win64 machine (targeted to either x86 or 64bit). I think I read somewhere the unmanaged DLL has to be changed with regard to DWORDs. Shame, I guess I will have to keep looking....
You reply to a code sample which was posted almost 14 years ago!!
And you don't give any information what you are doing or how you are doing it.Quote:
Jan 29th, 2005, 04:03 AM
If all can use VB6 to write code is good, VB6 can also write standard DLL