Escape the app context to call a global function


(Thomas Tempelmann) #1

I am using “Remote Buddy”. It lets me run applescript code, which apparently runs within RB’s context, i.e. I do not have to use ´tell app "Remote Buddy" to use its own classes and such.
Now, the problem is that I want to invoke the global open location function, but its code <<GURLGURL>> gets translated into the “Get URL” handler that RB itself offers.

How do I write my code so that it accesses the GURL handler on the global scope instead?

(Shane Stanley) #2

You could always try a different tack:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit"
use scripting additions

set theURLString to ""
current application's NSWorkspace's sharedWorkspace()'s openURL:(current application's |NSURL|'s URLWithString:theURLString)

(Thomas Tempelmann) #3

Didn’t think of using the ObjC Bridge. Works, but cumbersome.

So, that probably means that AppleScript has no language feature for accessing the parent scope. (such as “super of …”)

(Nigel Garvey) #4

A similar situation with PowerMail can be got round by telling any application which doesn’t implement a command using that code to perform it.

tell application "System Events" to open location ""

open location, by the way, is in the StandardAdditions.