Hello,
http://msdn.microsoft.com/msdnmag/is...0/cuttingedge/
I don't know if any of you are familiar with Dino Esposito article in
MSDN magazine on .NET Hooks but I used the class he created named
LocalWindowsHoo k that imports the below API calls
protected static extern IntPtr SetWindowsHookE x(HookType code,
HookProc func,
IntPtr hInstance,
int threadID);
and a few other necessary functions from user32.dll to implement a
hook.
I ended up changing his Install function from
public void Install()
{
m_hhook = SetWindowsHookE x(
m_hookType, m_filterFunc,
IntPtr.Zero,
(int)AppDomain. GetCurrentThrea dId());
}
to
public void Install()
{
m_hhook = SetWindowsHookE x(
m_hookType,
m_filterFunc,
GetHInstance(),
0);
}
public static IntPtr GetHInstance()
{
return
Marshal.GetHINS TANCE(System.Re flection.Assemb ly.GetExecuting Assembly().GetM odules()[0]);
}
In an attempt to create a global hook using WH_KEYBOARD.
The problem I have is it doesn't work. It works globally with
WH_KEYBOARD_LL but as soon as I use WH_KEYBOARD it doesn't work at
all. This meaning it doesn't capture keyboard strokes in either the
windows form or anywhere else. Now Dino's code worked fine for a
local hook (aka the form) but I want a global or system hook.
Now I have the class he wrote in an external DLL but there must be
something else i am missing. If anyone has any suggestions they would
be very much appreciated.
Thanks very much.
Dino Esposito modified project and my test windows form can be found
here
http://scaninc.ca/hook/globalhook.zip
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---