3

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

Cyrus Ngan
  • 199
  • 1
  • 6

1 Answers1

6

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")
Cyrus Ngan
  • 199
  • 1
  • 6
  • thank you, it took like 30 mins for me to find the right method name `openLocation` – XY L Apr 03 '18 at 07:02