|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Windows CBT Hooks (Help!)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 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#. <andyb***@gmail.com> wrote in message Show quote news:1168883242.169795.141610@38g2000cwa.googlegroups.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 > 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 > Hi Andy,
take a look at the following link, it might be able to help you: http://www.codeproject.com/csharp/GlobalSystemHook.asp Mark. Show quote "andyb***@gmail.com" wrote: > 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 > > |
|||||||||||||||||||||||