RBCAppleScript Class is a free REALbasic Class (for premium accounts users) that allows you to compile and run AppleScript code inside REALbasic without need to add AppleScript files to REALbasic Project. Hope you will find it useful and thx for support!
First add your RBCAppleScript Class to Project Tab and you reedy to rock. In this example we will tell application iTunes to play the music. If it’s not running then iTunes will automatically start.
1 2 3 4 5 | Dim applescript As New RBCAppleScript Dim ascode As String ascode= "tell application ""iTunes"" to play" applescript.Run(ascode) |
Using RBCAppleScript is also extremely easy to receive the data from AppleScript using RBCAppleScript.Result method. For example we can use AppleScript to get the name of every person from our Address Book app. This code will do this and display the received data in MsgBox, but a better way is adding it to a Array.
1 2 3 4 5 6 7 | Dim applescript As New RBCAppleScript Dim ascode As String ascode= "tell application ""Address Book"" to get the name of every person" applescript.Run(ascode) MsgBox applescript.Result |
RBCAppleScript allows you also to run multiline AppleScript code. To define next line use EndOfLine function like in this example:
1 2 3 4 5 6 7 8 | Dim applescript As New RBCAppleScript Dim ascode As String ascode= "tell app ""Finder""" + EndOfLine + "'Activate'" + EndOfLine + "display dialog ""REALbasic City""" + EndOfLine + "end" applescript.Run(ascode) MsgBox applescript.Result |
The original AppleScript looks so:
1 2 3 4 | tell application "Finder" activate display dialog "REALbasic City" end tell |
If you see this message you probably want access special material for Premium Members (Source Files, Bonus Tutorials, free Classes and More). You can do this by subscribing REALbasic City site for 10 USD (access for 3 months). There is also a option to buy access only to this material. Login or register to get option to buy and support REALbasic City.
Log in