I am writing a simple Automator script in JavaScript (because I’m much more productive in JavaScript). For testing purposes, I simply eval() the input.
The script is:
//  Workflow receives current text in any application
function run(input, parameters) {
    //  1+2*3
    
    var app = Application.currentApplication()
    app.includeStandardAdditions = true
    
//  app.displayDialog(input)
//  app.displayDialog(input[0])
    result = eval(input[0]) || 0;
    
    app.displayDialog(result)
    app.setTheClipboardTo(result)
    
    return result
}
//  Copy to Clipboard
I would like to get the result onto the clipboard. As you see above, I have applied the setTheClipboardTo() function.
The Workflow receives the current text.
I have also added the Copy to Clipboard action to the end.
I have tried with or without the setTheClipboardTo() function, and with or without the Copy to Clipboard action. The displayed message has the correct result, but I can’t get it to the clipboard.
