Re: hook calc.exe in vb

From: Joan (joanNOSPAMmundivia.com)
Date: 03/30/04


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)



Relevant Pages

  • Re: Lost with a systemwide hook
    ... They are controled by an app called QtDTAcer.exe. ... popup window does not appear when pressing the button. ... So I thought of a systemwide hook. ... LRESULT CALLBACK CInjectDll::HookProc(int nCode, WPARAM wParam, LPARAM ...
    (microsoft.public.vc.mfc)
  • Re: Hooking question
    ... I would like to record information about 'how the other app is used', ... You might want to take a look at the Computer Based Training hook. ... problem it lives to solve is not remote control but rather user training. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Shared Data Segment
    ... > that VB uses (c2 and link in the VB install directory). ... > tools are modified versions of the VC6 compiler so if you can play with ... what I seem to be finding is that the hook "breaks" as soon as Windows ... works if I activate another app and then go back to the original app. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Lost with a systemwide hook
    ... I created another app showing just a tray icon. ... DLL to set the systemwide hook. ... Deswegen kanst Du doch das versteckte Fenster in der Liste der Fenster finden und Tracen? ... Verstehe ich nicht. ...
    (microsoft.public.vc.mfc)
  • Re: hook crashes
    ... but not SendMessage in most cases. ... SendMessage carefully to a custom message to my VB App. ... There is a Timer ... > that every time I try to do something inside the hook procedure, ...
    (microsoft.public.vb.winapi)

Quantcast