0

I found an AppleScript example on a website that I want to use, and the example is rendered as text in the browser (vs., say, being a suitably formatted file to download).

To use this AppleScript, I'm assuming that I need to use Automator somehow to create a Workflow (or perhaps an Application), but I can't figure out the right way to paste the AppleScript (or otherwise enter free-form text) into Automator.

I tried dragging a Run AppleScript action into the workflow window and then pasting the the AppleScript there, and (after I cleaned-up the smart quotes) I was able to use the Run button to execute it from within Automator. Though it popped up a warning about not receiving input while running inside Automator, the AppleScript seemed to execute correctly (i.e., I ended up with the right result). But it seems like this might not be the correct/efficient way to do this transcription (and/or it will result in an inefficient AppleScript).

Is there some way to open a free-form text window in Automator to type in an AppleScript? Or is there some other way (other than trying to figure out each Action to drag into the workflow window and modify accordingly) to transcribe an AppleScript?

Corroborating my suspicions of inefficiency, I see that the resulting Application bundle/directory has a file called Contents/document.wflow and within that is the free-form pasted text as an ActionParameters member of Run AppleScript -- and this presumably will need to be parsed at every runtime.

I'm using Automator 2.7 on MacOS 10.12.6

  • 1
    You do not need to use Automator, just use Script Editor and save it as an application if you don't want to use it as a plain script. As to doing anything in Automator, you need to place the Actions you want to use into the workflow and do what is appropriate with each action used. The only issue I see with the linked script is the improper usage of smart-quotes, which you have already cleaned up. – user3439894 Jul 17 '18 at 15:37
  • @user3439894 I didn't realize that Script Editor was still around. The comments on the original site threw me. tnx! – jhfrontz Jul 17 '18 at 15:44
1

You might be making this more complicated than it needs to be. If you want the code from the other site in an applescript, that page provides guidance. You don't need Automator to simply run that script.

Copy the script text onto the clipboard. Launch the Script Editor. It should open a new and empty document. Paste the copied script. The text should appear as whatever your default is for new (or uncompiled) text, e.g. probably in a purple monospaced font.

Confirm that everything is hunky dory by compiling the script: Type Command-K (or from the menus: Script > Compile). It should take on the same appearance as what you saw on the other site, e.g. some words coloured or bolded (emboldened?). Depending upon whatever, you may find that the quotation marks have been altered and you get an error. They need to be straight double quotation marks, e.g. "" and not “”.

Then try it out. If it works as desired, save it somewhere easy to access, e.g. the Safari scripts folder. Then, if you have the Script menu enabled (check the box in the Script Editor General preferences), you will be able to run the script from the script icon that shows up on the right end of the menu bar (near the clock) whenever Safari is the active app.

/Users/username/Library/Scripts/Applications/Safari

NB I'd suggest saving it as a script (as opposed to application) unless you have a specific need that requires that.

0

I found that just copy / paste into a new automator window then save worked for me

  • My cut/copy/paste/delete are all grayed-out when I open a new workflow. Do you have start out with Automator in a certain state? – jhfrontz Jul 17 '18 at 15:18
  • Can’t check as I am on a smartphone, but I can guarantee I did copy/paste into one of the windows as I only type with two max 3 fingers... – Solar Mike Jul 17 '18 at 15:19
  • I seem to be able to copy/paste objects from a script within Automator. But I can't paste free-form text -- even when I copy the free-form text to the clipboard and then select an Action in the workflow window, I can only cut/copy/delete the Action (no paste) . – jhfrontz Jul 17 '18 at 15:29
  • Will look later but as I said I only have my phone with me... – Solar Mike Jul 17 '18 at 15:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .