Nico
Nico

Reputation: 1594

How to call Cocoa Methods from Applescript under OS X

In former OS X versions (pre 10.6) it was possible to call Cocoa methods via the "call method" command in applescript ("Applescript Studio"). E.g. this way: set theURL to "http://www.apple.com" set URLWithString to (call method "stringByAddingPercentEscapesUsingEncoding:" of theURL with parameter 30) The script interpreter in the "Applescript Editor" (10.6) does not understand the command "call method". - Is there an equivalent for "Applescript Editor" (10.6)?

Upvotes: 5

Views: 2030

Answers (2)

regulus6633
regulus6633

Reputation: 19030

You can use "call method" in applescript. Apple gave that ability to Automator and we can access that ability from applescript by using the "Automator Runner" application. I just showed this to someone recently. See my post #4 here.

So to answer your question, just put your "call method" code inside a tell application "Automator Runner" tell block.

Upvotes: 3

Seb Jachec
Seb Jachec

Reputation: 3061

AppleScript Studio I thought was done in Xcode not AppleScript Editor. Code in AppleScript Editor can only be saved as scripts and the language is just plain AppleScript.

If you're doing this is Xcode, on 10.6, AppleScript Studio no longer exists. It's now AppleScript-Obj-C

I don't know an exact answer.. but...

If you take - (void)makeKeyAndOrderFront:(id)sender in AppleScript-Obj-C, if I have a property linked to a window in Xcode I just go: myWindowProperty's makeKeyAndOrderFront_(sender)

I hope this helped at least a bit!

Upvotes: 1

Related Questions