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 / New Users / January 2007

Tip: Looking for answers? Try searching our database.

Windows CBT Hooks (Help!)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
andyblum@gmail.com - 15 Jan 2007 17:47 GMT
I hope you can answer a question.  I am writing a poker utility that
tracks what windows are open and displays information about opponents
that are still playing and their previous history that is stored in a
game DB.  It is a very cool project with Pattern Recognition (Pixel
Screen SCraping to OCR) and pretty advanced calculations.  I
just started writing my first prototype in C# and discovered that I
could not set a System Wide CBT hook.

.Net will not allow hooks CBT hooks to be set globally, period!  Works
for mouse and keyboard, but not CBT.

I need to trap when a window is created, destroyed, gotfocus, or
resized.  I do not want to cancel or redirect those messages.  I just
need to get new rect information about the window.

I have discovered ways of doing it in either VB6 or C++.  I am not sure
which is the best strategy to pursue.  I do not code in either
language.  Can I have this hook in VB or C++ and then call my C#
function?  Anone have any suggestions for interacting in between
managed and unmanaged code when the unmanaged code needs to trigger a
C# method?  

Thanks,

Andy
Ashot Geodakov - 15 Jan 2007 23:30 GMT
Your best bet is a Windows Hook DLL written in C++ that will combine Win32
API for hooks and managed C++ for interaction with your C#.

You don't need to be C++ savvy, just use one of the MSDN samples as a
template. First, use their sample to create your hook DLL. Then add CLR
support to the sample and create a managed (ref) C++ class which you will
use to send data to C#.

>I hope you can answer a question.  I am writing a poker utility that
> tracks what windows are open and displays information about opponents
[quoted text clipped - 21 lines]
>
> Andy
Mattias Sjögren - 16 Jan 2007 06:37 GMT
>Your best bet is a Windows Hook DLL written in C++ that will combine Win32
>API for hooks and managed C++ for interaction with your C#.

No, the hook library can't be a mixed mode DLL. Pure native code. He
has to find another way to communicate events back to the C# 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.

Mark R. Dawson - 16 Jan 2007 01:48 GMT
Hi Andy,
 take a look at the following link, it might be able to help you:
http://www.codeproject.com/csharp/GlobalSystemHook.asp

Mark.
Signature

http://www.markdawson.org
http://themightycoder.spaces.live.com

> I hope you can answer a question.  I am writing a poker utility that
> tracks what windows are open and displays information about opponents
[quoted text clipped - 21 lines]
>
> Andy
Peri - 26 Jan 2007 08:15 GMT
> I hope you can answer a question.  I am writing a poker utility that
> tracks what windows are open and displays information about opponents
[quoted text clipped - 3 lines]
> just started writing my first prototype in C# and discovered that I
> could not set a System Wide CBT hook.

Wow. I'm playing some poker and was thinking about writing same software.  
What pokerroom You are trying to write this software for? Why don't You  
read history files? What poker network is this that it doesn't use  
standard windows controls in its poker software so that You have to OCR? I  
know of one. Boss Media.

Signature

Peri


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.