Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / May 2006

Tip: Looking for answers? Try searching our database.

using a BHO to capture key strokes from IE alone

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hema - 10 Apr 2006 16:07 GMT
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
Mattias Sjögren - 10 Apr 2006 20:17 GMT
>I have developed a BHO that installs low level keybaord hooks and CBT
>hooks globally

You can't implement global CBT hooks in managed code.

Mattias

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Hema - 11 Apr 2006 06:23 GMT
Hi,
So my mistake is in trying to develope a CBT hook globally? If i make
this application i.e. both keyboard hook and CBT thread specific,will
it b fine?

Thanks for your reply.
Regards,
hema
mabra - 28 May 2006 16:17 GMT
Hi !

Have a look for http://www.codeproject.com/csharp/GlobalSystemHook.asp
This contains a small [managed] C++ library which should allow global hooks.

I've not verified this and I am not an expert on this theme. So far I
understand the limitation, you should be able to create a hook for your
IE, but not globally [without the above mentioned helper dll].

Regards,
Manfred

> Hi,
> So my mistake is in trying to develope a CBT hook globally? If i make
[quoted text clipped - 4 lines]
> Regards,
> hema

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.