Professional Web Applications Themes

Does Mac OS have windows like hooking API? - Mac Programming

Hi - We have a CBT product for the windows platform that uses windows system level programming (specifically uses hooking APIs) to understand user interactions with a program. We check if the user chose the right menu option, entered the expected data value etc. We are exploring if we can port some of our CBTs to the mac OS platform. Does the mac OS have something equivalent to windows hooking APIs that we can use to determine user actions? Any information will be highly appreciated. Sincerely, John...

  1. #1

    Default Does Mac OS have windows like hooking API?

    Hi -

    We have a CBT product for the windows platform that uses windows system
    level programming (specifically uses hooking APIs) to understand user
    interactions with a program. We check if the user chose the right menu
    option, entered the expected data value etc.

    We are exploring if we can port some of our CBTs to the mac OS platform.
    Does the mac OS have something equivalent to windows hooking APIs that we
    can use to determine user actions?

    Any information will be highly appreciated.

    Sincerely,
    John



    John Guest

  2. #2

    Default Re: Does Mac OS have windows like hooking API?

    On Sat, 28 Feb 2004, John wrote:
     

    Hard to say without knowing what hooking or CBT are, but I'd guess that
    Carbon Events is what you want. Most objects (eg windows, controls etc)
    can have a standard handler, but you can install handlers to deal with
    specific events.

    Fred

    Frederick Guest

  3. #3

    Default Re: Does Mac OS have windows like hooking API?

    In article <aH80c.4145$news.prodigy.com>,
    "John" <com> wrote:
     

    CBT == computer based training?
     

    You can do this pretty thoroughly under OS X 10.2 and later using
    the Accessibility API.

    http://developer.apple.com/samplecode/Sample_Code/OS_Utilities/UIElementInspector.htm

    There should also be a compiled copy of the program in the developer
    download area.

    You can do more limited instrumentation using Apple Events on older
    Mac systems, if the program you're interested in supports it.
    iMeowbot@mac.com Guest

  4. #4

    Default Re: Does Mac OS have windows like hooking API?

    Yes, Carbon Events will get you much of the interaction you're
    seeking. You may want to concentrate on 'Carbon with NIB' examples so
    you can a variety of situations in a non-objective-C fashion, since I
    imagine you'll want to use C++.
    Neil Guest

  5. #5

    Default Re: Does Mac OS have windows like hooking API?

    In article
    <srcf.societies.cam.ac.uk>
    ,
    Frederick Cheung <DUH.ucam.org> wrote:
     
    >
    > Hard to say without knowing what hooking or CBT are, but I'd guess that
    > Carbon Events is what you want. Most objects (eg windows, controls etc)
    > can have a standard handler, but you can install handlers to deal with
    > specific events.[/ref]

    And if you need to watch events in other processes, I believe there's a
    Carbon Event way as of 10.3 to watch (but not modify) events that occur
    in other apps.

    -Eric

    --
    Eric Albert stanford.edu
    http://rescomp.stanford.edu/~ejalbert/
    Eric Guest

  6. #6

    Default Re: Does Mac OS have windows like hooking API?

    In article <aH80c.4145$news.prodigy.com>,
    "John" <com> wrote:
     

    I'll assume CBT is Computer Based Training.
     

    *which* MacOS platform? MacOS 9? MacOS X? I'll presume that you're only
    now starting to work that you're porting to MacOS X, ok? If you're
    interested in MacOS 9 or earlier, you may want to have a look at "Apple
    Guide", which used to be Apple's ingenious help API and which provided a
    lot of stuff for free.
     

    It might help if you detailed what those "windows hooking APIs" do. It
    might also help to tell us how much control you have over the targeted
    applications. Also, is your CBT stuff running as part of that other
    application, or as a separate application?

    Depending on each of these, it may be as easy as just intercepting
    Carbon Events or overriding the a method in NSApplication, or it may be
    more complicated like using Accessibility or even injecting some code
    into that other application to do one of the above things outside of
    your own app. (The Extendamac mailing list and project at
    http://extendamac.sourceforge.net
    might be a good starting point for learning about the latter).

    That being said, injecting code into other applications poses the risk
    of injecting your bugs into that other application as well, so if any of
    the "official" mechanisms allow doing what you want, I'd urge you to use
    those instead. And if they don't, be sure to include lots of sanity
    checks and give the user the option of doing without the functionality
    that requires injection in case they fail. (i.e. openly, in a dialog,
    not as an option that can be set using a command-line program or by
    editing the preferences file).

    HTH,
    -- Uli
    http://www.zathras.de
    Uli Guest

  7. #7

    Default Re: Does Mac OS have windows like hooking API?

    Thanks all of you for your valuable input. Your responses have given me
    enough information on where to start my study.

    Your help is highly appreciated.

    John

    "John" <com> wrote in message
    news:aH80c.4145$news.prodigy.com... 


    John Guest

  8. #8

    Default Re: Does Mac OS have windows like hooking API?

    In article <uPX0c.4953$news.prodigy.com>,
    "John" <com> wrote:
     

    John,

    it would be nice if you could post your results here. That way, someone
    searching for the answer to this question (e.g. via Google groups) won't
    have to ask the same question again.

    I'd personally be pretty interested in learning how these Windows
    "hooking" APIs correspond to the existing Mac mechanisms.

    Cheers,
    -- Uli
    http://www.zathras.de
    Uli Guest

  9. #9

    Default Re: Does Mac OS have windows like hooking API?

    OK, I will. It might be a little while though :)

    John.

    "Uli Kusterer" <de> wrote in message
    news:t-online.com... 
    >
    > John,
    >
    > it would be nice if you could post your results here. That way, someone
    > searching for the answer to this question (e.g. via Google groups) won't
    > have to ask the same question again.
    >
    > I'd personally be pretty interested in learning how these Windows
    > "hooking" APIs correspond to the existing Mac mechanisms.
    >
    > Cheers,
    > -- Uli
    > http://www.zathras.de[/ref]


    John Guest

  10. #10

    Default Re: Does Mac OS have windows like hooking API?

    Windows Hooking for Mac guys (from a Mac guy who had to learn it)

    Windows hooks work on the basis of a function getting called with an event
    of some type, taking some sort of action, then passing the event to the next
    hook. Some allow modifying or deleting the event, others only let you see it
    as it goes by.

    There are several different types of hooks. They differ in which events they
    receive and when, what data is available, and what can be done with the
    event. CBT Hooks (Computer Based Training) tend to be the most useful in
    most cases, since they cover a wide range of events.

    Any application can install a hook local to itself. The process is fairly
    similar to the Mac trap patching except that it patches an event instead of
    an API. This type of hook ONLY sees events inside an application'e process
    space.

    A global hook affects ALL processes on the machine that are started AFTER
    the hook is installed. These have to be located in a DLL: once the hook
    function (exported from the DLL) is installed, the DLL will automatically
    load into every new process and be applied there. A global hook can be
    installed or removed by any application. The closest Mac equivalent is the
    jGNE Filter technique from the good old days.

    I recently used hooks to implement a popup blocker for IE: a small app was
    launched, loaded the DLL and applied the hook; every instance of IE
    thereafter was affected. The hook caught (among other things) window
    creation events and decided whether the window was a popup that needed to be
    deleted before appearing (harder than it sounds!) or a legitimate window.
    The DLL's init code is called every time it links to a new process, so I
    could check for IE and disable the hook for other applications. There is
    also a way to share memory between different processes using the hook DLL,
    so they can talk to each other.

    Buggy hooking can destroy the stability of the entire system, and there is
    an obvious impact on system performance if too many are installed or too
    much processing is done.

    Search MSDN.microsoft.com for more information. Incidentally, hooks aren't
    directly supported under .NET for the same reason OS X doesn't have trap
    patching.





    "Uli Kusterer" <de> wrote in message
    news:t-online.com... 
    >
    > John,
    >
    > it would be nice if you could post your results here. That way, someone
    > searching for the answer to this question (e.g. via Google groups) won't
    > have to ask the same question again.
    >
    > I'd personally be pretty interested in learning how these Windows
    > "hooking" APIs correspond to the existing Mac mechanisms.
    >
    > Cheers,
    > -- Uli
    > http://www.zathras.de[/ref]


    Paul Guest

Similar Threads

  1. Replies: 2
    Last Post: July 30th, 01:46 PM
  2. Replies: 5
    Last Post: May 14th, 10:03 PM
  3. Replies: 4
    Last Post: January 13th, 07:27 PM
  4. Replies: 1
    Last Post: July 22nd, 04:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139