Communicating via AppleEvents with Revolution applications
Kee Nethery
kee at kagi.com
Thu Jul 16 15:02:17 EDT 2009
I have a program that is not in Revolution that needs to send commands
with data and receive results from a Revolution application. I worked
this out a while ago and found that I had to re-learn it so figured
I'd document my recipe and post it to the group.
This is what worked for me. I am running Leopard (Mac OS X 10.5.7) on
Intel, and using Revolution 2.9.0.
1. Open Revolution
2. File / New Mainstack
3. Object / Stack Script
4. enter the following script
on barklikeadog urlEncodedStuff
put urldecode(urlEncodedStuff) into theData
return "arf arf" && the seconds && theData
end barklikeadog
5. Apply, close the stack script
6. Object / Stack Inspector
Name: AppleEventCatcher
7. close the inspector
8. File / Save
9. File / Standalone Application Settings
10. Windows
Build for: (de-select the checkbox)
11. close the Standalone Application Settings window
12. File / Save
13. File / Save As Standalone Application
14. Quit Revolution
(15. In 2.9.0 these steps are not needed. In 2.8.x they were:
15a. in the Finder, go to the newly created Mac application
"AppleEventCatcher" and with the control key down, click on the
application. Select "Show Package Contents"
15b. Go to Contents / Resources / Revolution.rsrc and change the name
of that file to AppleEventCatcher.rsrc
15c. close the Show Package Contents window)
16. Launch AppleEventCatcher application.
17. Open Apple's Script Editor.
18. In the script window enter the following script:
property thescript : []
property theresult : []
on run
copy "send \"barklikeadog hello%20world\"" to thescript
tell application "asdfgh"
activate
do script thescript
put the result into theresult
end tell
display dialog theresult
end run
19. Press the Compile button and it will ask you where "asdfgh" is
located. Select the newly created Mac application "AppleEventCatcher"
20. File / Save (might as well save your AppleScript)
21. Press the Run button
22. The dialog box presented by the Script Editor should display
something like:
"arf arf 1206236082 hello world"
The data coming back does not need to be URL encoded, it seems to
travel back just fine.
The tricks are having the script be a send command, putting quotes
around the script being sent, and when sending multiple variables, URL
encoding them into one variable.
I don't know what kinds of payload limits there are going to and
coming from the application.
More information about the use-livecode
mailing list