How to Call Cocoa Methods from Applescript under OS X

In previous versions of OS X (prior to 10.6), you could call Cocoa methods using the "call method" command in applescript ("Applescript Studio"). For instance. here: set theURL to " http://www.apple.com " set URLWithString to (call method "stringByAddingPercentEscapesUsingEncoding:" of theURL with parameter 30) interpreter script in "Applescript Editor" (10.6) does not understand the command "call method". - Is there an equivalent for Applescript Editor (10.6)?

+4
source share
2 answers

You can use the "calling method" in applescript. Apple provided this feature to Automator, and we can access this feature from applescript using the Automator Runner app. I just recently showed it to someone. See my post # 4 here .

So, to answer your question, just put your code โ€œcall methodโ€ inside the tell application โ€œStartup Blockโ€ .

+3
source

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

If you do this, Xcode, at 10.6, AppleScript Studio no longer exists. Now AppleScript-Obj-C

I do not know the exact answer .. but ...

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

Hope this helps at least a little!

+1
source

Source: https://habr.com/ru/post/1333392/


All Articles