By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,146 Members | 1,813 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,146 IT Pros & Developers. It's quick & easy.

hooking the keyboard from IE

P: n/a
Hi all,
I have developed a BHO that installs low level keybaord hooks and CBT
hooks globally whenever IE is opened.The keys that are pressed when IE
is active are to be captured.I am trying to check whether the IE is
active first, If it is i set a boolean flag.In the key hook proc ,if
the flag is set, the keys are sent for further processing.The keyboard
hooks is working fine(when checked separately), but the CBT hooks is
not working properly. The IE page is taking a long time to load and
after it loads, its not informing me abt whether the IE is active. The
only code returns is the Window creations.Nothing else is happening.
My hook proc is as follows:
public static int CbtHookProc(int nCode, IntPtr wParam,IntPtr lParam)
{
StringBuilder title = new StringBuilder();
string classname;
title.Capacity=10;
if(nCode==HCBT_ACTIVATE)
{
try{
GetClassName(wParam,title,10);
classname=title.ToString();
if(classname.StartsWith("IE"))
IE_Active=true; //an bool variable set to false initially
else
IE_Active=false;
}
catch(Exception e) {
MessageBox.Show(e.ToString());
}
}
return CallNextHookEx(CBTHook,nCode,wParam,lParam);
}
Win32 Import for GetClassName is as follows:
[DllImport("user32.dll")]
protected static extern int GetClassName(IntPtr hwnd,
StringBuilder lpClassName, int nMaxCount);

Is this correct?If so , y is this not working? wat am i missing in
this?.
thanks and regards,
Hema

Apr 10 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.