javascript-automation

Can you write folder actions with javascript (jxa)?

半城伤御伤魂 提交于 2019-12-02 06:53:08
I am looking for a direct translation of AppleScript's on adding folder items to this_folder but I can't seem to find it anywhere, neither the usage of the terms or the keyword this_folder itself. Pierre Forestier Using Automator I could build a Folder Action workflow to display the path of a file moved to a folder using only JavaScript: function run(input, parameters) { var app = Application.currentApplication(); app.includeStandardAdditions = true; var text = "FileName = " + input[0]; var options = { }; app.displayAlert(text, options); return input; } I hope that could help. Folder Actions

How do you run inline Applescript from a JXA/JavaScript for Automation script on macOS?

泄露秘密 提交于 2019-12-01 01:45:03
I have a script written in JavaScript which needs to run one small piece of AppleScript (to achieve some functionality I've been unable to implement due to a number of factors natively in JS). It should be able to take a single string argument, and is pretty much a tell-endtell one liner. Is it possible to assemble this nanoprogramme as a string in JavaScript then pass the string to the AppleScript environment for execution, and how would that be done? There's plenty of explanations online about how to run JavaScript from Applescript, but not as much coming the other way. Would this - in all

How do you run inline Applescript from a JXA/JavaScript for Automation script on macOS?

断了今生、忘了曾经 提交于 2019-11-30 21:17:45
问题 I have a script written in JavaScript which needs to run one small piece of AppleScript (to achieve some functionality I've been unable to implement due to a number of factors natively in JS). It should be able to take a single string argument, and is pretty much a tell-endtell one liner. Is it possible to assemble this nanoprogramme as a string in JavaScript then pass the string to the AppleScript environment for execution, and how would that be done? There's plenty of explanations online