Re: hook calc.exe in vb
From: Joan (joanNOSPAMmundivia.com)
Date: 03/30/04
- Next message: Joan: "Re: hook calc.exe in vb"
- Previous message: Randy Birch: "Re: Problem with RegQueryValueEx"
- In reply to: Tom Esh: "Re: hook calc.exe in vb"
- Next in thread: Randy Birch: "Re: hook calc.exe in vb"
- Reply: Randy Birch: "Re: hook calc.exe in vb"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 30 Mar 2004 07:43:10 +0200
Hi Tom, thanks for your answer,
I'm not really sure that hook is the best way to do that (in fact, the only
thing I want to achieve is to trap the moment that the user uses Escape key
so I can terminate calculator app). If you coul tell me another or better
way to do it, I will be very thankfull. I'm not an expert with API
programming.
However I'll have a look at what you tell me.
Thank you very much.
Joan
"Tom Esh" <tjeshGibberish@earthlink.net> escribió en el mensaje
news:qteh605dm3t74a46pcgvjqi1l3bhe7ej2g@4ax.com...
> On Tue, 30 Mar 2004 00:39:56 +0200, "Joan" <joanNOSPAMmundivia.com>
> wrote:
>
> >I'm trying to hook the application "calc.exe" and trap some keyboard
> >movements. I've seen some code in allapi.com that I think could help me,
but
> >I don't know the values I should put in substitution of App.hInstance and
> >App.ThreadID, and how to know them
> >
> > hHook = SetWindowsHookEx(WH_KEYBOARD, AddressOf KeyboardProc,
> >App.hInstance, App.ThreadID)
> >....
>
> Problem is if you intend to hook other apps/threads, the WH_KEYBOARD
> callback must reside in a separate standard (C) dll. You'll get a
> crash trying to do it from within your app. If you're sure a windows
> hook is the way to go, here are two options:
> 1) Check out the free DS_ hook components with VB examples (i.e.
> separate standard dlls) at AllApi.
> 2) Use a WH_KEYBOARD_LL hook instead (Win2K / XP only). It doesn't
> inject the calling process, so it will work within your app.
>
> Either way be advised windows hooks can be decidedly unfriendly to the
> VB IDE. You will not be able to step through code to debug it while a
> hook is active without crashing the IDE. (Save often and become one
> with Debug.Print. <g>)
>
>
> -Tom
> MVP - Visual Basic
> (please post replies to the newsgroup)
- Next message: Joan: "Re: hook calc.exe in vb"
- Previous message: Randy Birch: "Re: Problem with RegQueryValueEx"
- In reply to: Tom Esh: "Re: hook calc.exe in vb"
- Next in thread: Randy Birch: "Re: hook calc.exe in vb"
- Reply: Randy Birch: "Re: hook calc.exe in vb"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|