Windows CBT Hooks (Help!)

A

andyblum

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
 
A

Ashot Geodakov

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#.
 
M

Mattias Sjögren

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
 
P

Peri

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.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

CBT Hook 1
Raw Input Global Hooks 0
Window Hooks 1
Hooks with C# 2
Global Hook for Window Painting 2
WH_JOURNALPLAYBACK and WH_JOURNALRECORD hooks 0
Global Mouse Hooks in C# 3
Console Window Hooks 0

Top