javascript for automation [open location in finder

2019-05-13 22:45发布

问题:

I am trying to figure out how JXA(JavaScript for Automation) works, so try to translate a simple applescript as below to JXA.

tell application "Finder"
    open location "smb://XXXXXXXX"
end tell

what I tried is here:

finder = Application("Finder")
finder.open({location:"smb://xxxxxx"})

but I fail..., and I am new to applescript, not really understand the description in library. and here is how the library describe the open

open (v) : Open the specified object(s)
open specifier : list of objects to open
  [using specifier] : the application file to open the object with
  [with properties record] : the initial values for the properties, to be included with the open command sent to the application that opens the direct object

please kindly advise how should I amend the code. ^^ Thanks

回答1:

Oh ... I got the Ans..., it's nothing about Application("Finder"), it is for standardAdditions

app = Application.currentApplication()
app.includeStandardAdditions = true
app.openLocation("smb://xxxxxxxx")