Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

Watch applications send and receive Apple Events System

Applications use Apple Events to communicate among themselves. If you've ever wondered what they're saying behind your back, just open the Terminal and type:

 % setenv AEDebugSends 1 
 % setenv AEDebugReceives 1 
 % /usr/bin/osascript -e 'quit application "Finder"'
 % /usr/bin/open -a "Finder"
Any applications you then open with the Finder will report the events they send and receive to the Console. Read the rest of the hint for an example of what you'd see...

For example, suppose you use the Finder to open Safari, then you double-click on a .webloc file on the desktop. In the Console, you will see the Finder send the "go to URL" event and Safari receive it:

AE2000 (474): Sending an event:
------oo start of event oo------
{ 1 } 'aevt':  GURL/GURL {
          return id: 31064065 (0x1da0001)
     transaction id: 0 (0x0)
  interaction level: 112 (0x70)
     reply required: 0 (0x0)
  target:
    { 2 } 'psn ':  8 bytes {
      { 0x0, 0x2e0001 } (Safari)
    }
  optional attributes:
    < empty record >
  event data:
    { 1 } 'aevt':  - 1 items {
      key '----' - 
        { 1 } 'TEXT':  21 bytes {
          "http://www.apple.com/"
        }
    }
}

------oo  end of event  oo------
AE2000 (477): Received an event:
------oo start of event oo------
{ 1 } 'aevt':  GURL/GURL {
          return id: 31064065 (0x1da0001)
     transaction id: 0 (0x0)
  interaction level: 112 (0x70)
     reply required: 0 (0x0)
  target:
    { 1 } 'psn ':  8 bytes {
      { 0x0, 0x2c0001 } (Finder)
    }
  optional attributes:
    < empty record >
  event data:
    { 1 } 'aevt':  - 1 items {
      key '----' - 
        { 1 } 'TEXT':  21 bytes {
          "http://www.apple.com/"
        }
    }
}

------oo  end of event  oo------

In the above, the Unix process IDs are in parentheses, in this case (474) and (477). The tag psn indicates the Process Serial Number, in hexadecimal. (When sending, the event target is the receiving process; when receiving, the target is the sending process.) The URL being opened is http://www.apple.com/.

    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[11,629 views]  

Watch applications send and receive Apple Events | 6 comments | Create New Account
Click here to return to the 'Watch applications send and receive Apple Events' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Monitoring ALL Apple events
Authored by: noworryz on Fri, Mar 21 2003 at 11:09AM PST

Doing what the hint suggests monitors events being sent and received by the Finder and the applications it launches. Monitoring stops when your log out. If you want to permanently turn on monitoring of all Apple events, whenever you log in, you can add AEDebugSends and AEDebugReceives to your ~/.MacOSX/environment.plist file, defining their values as 1.

You may have to create the both the directory and the file. Apple's QA1067 document tells you how.

--Glenn

[ Reply to This | # ]

Monitoring specific applications?
Authored by: gctuser on Sun, Mar 23 2003 at 1:01PM PST
Is it possible to set the environmnt variable in a way that restricts the console-output to specific applications?

[ Reply to This | # ]
Viewing events of a single application
Authored by: noworryz on Sun, Mar 23 2003 at 3:33PM PST

I've been asked if it is possible to restrict event viewing to a single application. You can do this by only launching one application with the environment variables set. For example, launch YourApp from the terminal as follows:


setenv AEDebugSends 1
setenv AEDebugReceives 1
open -a "YourApp"

--Glenn

[ Reply to This | # ]

Watch applications send and receive Apple Events
Authored by: Vocal Velocity on Mon, Dec 6 2004 at 1:49PM PST
how would this be done using the bash?
setenv is not available and export does not seem to like it either?

[ Reply to This | # ]
Watch applications send and receive Apple Events
Authored by: jimr on Mon, Jul 3 2006 at 1:45AM PDT
put:
<pre>#Sets AEDebug in the terminal
export AEDebugSends = 1
export AEDebugReceives = 1
</pre>
in your login script (e.g. ~/.profile)
<br><br>
Though it seems that when .MAOSX/environment.plist exists, this is already there.

---
-----------------


[ Reply to This | # ]
Apple Events Debugging: CAVEAT
Authored by: jimr on Mon, Jul 3 2006 at 2:33AM PDT
This is an old hint, but still works.

At sometime I certainly installed the environment.plist file in my system, watched for Apple events, and promptly forgot about how it was done. Possibly, It was installed by an app called AE Monitor.

There are a few caveats.. first, it fills up your console.log with this debugging data as well, and several times I was able to use it, so I never got too worried about that...

Second, and this has been a major problem, as it took a very long time to come to a solution, it seems that AE debugging interferes with BBEdit's sftp logins. Though, every other application supporting the sftp protocol, and the command line seem to work just fine.

Now I had never seen this reported anywhere, and for some time I supposed it was a bug in either My Operating System (heavily tweaked), or in some other faulty configuration.

I searched EVERYWHERE for answers to the sftp problem. but have had no luck during the year or more that the problem has been following me around.

And, when I say following me, I mean, that I finally determined that BBEdit sftp was working just fine on any other account in my room and on *gasp* my machine...

It wasn't a super serious fault in my favorite text editor, especially as the excellent CYBERDUCK sftp client will work seamlessly with the text editor of choice...

It was just at the lower threshold of PITA... and so I let it slide for quite a long time, though, it was a bit frustrating.

So today, midst some system maintenance and upgrades , I decided to more carefully examine some of the differences between the normal login account and the spare account.

I noted that the AEDebugging was not global, and as I was looking for a non-global setting, I started to investigate in earnest.

Google soon led me to this hint as I was looking for a source of AE2000 debugger statements in my logs... so, here is one way to put them there..

And I surely found the ~/.MACOSX directory absent in the spare user account where things work perfectly, yet have none of my special customization ;-)

upon removal, and a restart... (Well.... the newest QT installer wanted that...)

The BBEdit sftp no longer fails upon activation and of course the logs will be free of AE property list declarations...
As you can read the hint, it's easy to turn back on... but it seems, you never know when some app, even the well written ones, will fail due to some customization.

Finally for the search engines... this BBEdit failure during sftp login is solved by disabling AEDebug

Though, as a developer, one may actually require AEDebugging and BBEdit sftp simultaneously ;-)

---
-----------------


[ Reply to This | # ]