May someone refer me an good API Hook tutorial?
I've been looking for a way to leave keys and mouse changes at another application without having it active. My research sent me to API Hook but I can't find a good tutorial on how to use it properly. Thank you.
Sergio FonsecaPosted Mar 6, 2008, 12:47 PM
AlanPosted Mar 6, 2008, 5:37 AM
Basically, you need to get the other application's window handle (and possibly the handles of controls within that window) and then send them the appropriate messages
As long as the other application is not hidden, you should be able to obtain its handle using the System.Diagnostics.Process.GetProcessesByName method to get the Process object itself and then obtain its MainWindowHandle property.
Alternatively you can use the API funtion FindWindow (or FindWindowEx) and then use SendMessage to send the actual messages.
I had a quick google to see if I could find any sample code and found this thread which is a mixture of VB.Net and C# code but I think you'll be able to follow it OK, even if you don't really know VB.Net:
http://www.vbforums.com/showthread.php?t=505548
For details on the constant values to use with the API functions, I'd check out this site:
http://pinvoke.net/
Sergio FonsecaPosted Mar 5, 2008, 6:48 PM
Thank you Alan. Your ever helpful here I'll read and watch this page you sent me deep.
I read the tutorial but it just capture the keys and mouse movements how do exactly I simulate them in another application without having it as active window?
AlanPosted Mar 5, 2008, 6:51 AM
Have a look at this Code Project article and other articles to which it refers for information on global hooks:
http://www.codeproject.com/KB/cs/globalhook.aspx