Search code examples
javascriptmacosapplescriptfinder

AppleScript to Javascript


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.


Solution

  • 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();