javascript for automation [open location in finder]

血红的双手。 提交于 2019-12-22 09:26:07

问题


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")


来源:https://stackoverflow.com/questions/27915602/javascript-for-automation-open-location-in-finder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!