admin管理员组

文章数量:1263928

What is the equivalent below code in Javascript? Is this apple script convertable to java script?

tell application "Finder"
    activate
    set position of Finder window 1 to {607, 276}
    close Finder window 1
end tell

Thanks.

What is the equivalent below code in Javascript? Is this apple script convertable to java script?

tell application "Finder"
    activate
    set position of Finder window 1 to {607, 276}
    close Finder window 1
end tell

Thanks.

Share Improve this question asked Apr 5, 2012 at 3:51 mh taqiamh taqia 3,5961 gold badge26 silver badges37 bronze badges 4
  • This might do what you want: jstalk – brettkelly Commented Apr 5, 2012 at 3:54
  • I want to run this code by JavascriptCore framework. Is it possible? I am Windows programmer and beginner in Mac. – mh taqia Commented Apr 5, 2012 at 4:11
  • check out JSTalk, as linked above by @inkedmn – it’s built on top of JavascriptCore. Just out of interest: why do you want to use JavaScript for this? – kopischke Commented Apr 5, 2012 at 12:14
  • 2 Because Javascript is public and popular and I am familiar with it. Can I do Scripting InDesign CS4, CS5, ... with js talk? How I can reference Application Object? and can I use it in carbon apps? Tnx – mh taqia Commented Apr 7, 2012 at 8:34
Add a ment  | 

2 Answers 2

Reset to default 11

Since the release of OS X Yosemite, JavaScript is available to automation.

The equivalent of your code would be:

var finder = Application('Finder');

finder.activate();
finder.windows[0].position = {x: 607, y: 276};
finder.windows[0].close();

You can use node js module: https://github./TooTallNate/node-applescript

本文标签: macosAppleScript to JavascriptStack Overflow