Re: hook calc.exe in vb
From: Tom Esh (tjeshGibberish_at_earthlink.net)
Date: 03/30/04
- Next message: MikeD: "Re: Getting information from External Window"
- Previous message: MikeD: "Re: ARRGH! Help!"
- In reply to: Joan: "hook calc.exe in vb"
- Next in thread: Joan: "Re: hook calc.exe in vb"
- Reply: Joan: "Re: hook calc.exe in vb"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 29 Mar 2004 19:15:33 -0500
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: MikeD: "Re: Getting information from External Window"
- Previous message: MikeD: "Re: ARRGH! Help!"
- In reply to: Joan: "hook calc.exe in vb"
- Next in thread: Joan: "Re: hook calc.exe in vb"
- Reply: Joan: "Re: hook calc.exe in vb"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|