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