Action

AS External Call Action

Posted by sylumer, Last update about 4 years ago - Unlisted

Steps

  • script

    function runExternalAppleScript(p_strASPath, p_strArgument)
    {
    	// Initialise the script
    	let runScriptContents = `#!/bin/zsh	
    osascript "${p_strASPath}" "${p_strArgument}"
    `;
    	let runScript = ShellScript.create(runScriptContents);
    	// Run the script and if necessary deal with any errors
    	if(!runScript.execute())
    	{
    		context.fail(`Running "${p_strASPath}" failed.`);
    		console.log("STDERR: " + runScript.standardError);
    	}
    	// Always log and return the standard output on a success or failure
    	console.log("STDOUT: " + runScript.standardOutput);
    	return runScript.standardOutput;
    }
    
    draft.content = draft.content + "\n" + runExternalAppleScript("/Users/stephen/Library/Mobile Documents/com~apple~CloudDocs/AppleScripts/nato.scpt", editor.getSelectedText());
    draft.update();
    
    
    

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.