Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AppleScript Editor record doesn't work

I have opened the AppleScript Editor and pressed Record button.

Then I run TextEdit, create a file and put some text there.

When I click the Stop button in AppleScript Editor, nothing was recorded, the window is blank.

What is the problem?

like image 855
never_had_a_name Avatar asked Aug 22 '10 18:08

never_had_a_name


People also ask

How do I record a script in AppleScript?

Click Record, perform the actions you want to record, then click Stop. The Script Editor only records actions that change a document, setting, or other aspect of the application.

How do I run an AppleScript on a Mac?

In the Script Editor app on your Mac, click the Run button in the toolbar, or press Command-R, to execute the commands in your script.

How do you edit AppleScript?

EDITING A SCRIPT You are going to edit it so that it can actually open the fragment editors of each of the selected sequences. From the AppleScript Editor File menu choose Open and locate the script called "Edit this Script" inside the Sample Data's AppleScript folder. Select the script and click the Openbutton.


2 Answers

You can use the Record feature of the Automator to record the UI interaction steps needed to do the relevant workflow. Then you can then literally select and copy the recorded steps in automator and paste them into a new Applescript Editor window. This will give you applescript which may or may not work. You'll probably want/need to edit the resulting script, but at least it should help give an idea what is needed to achieve your workflow programatically. This method is usable regardless of whether or not the target application has an applescript dictionary or supports the AppleScript Editor Record button, as it is the interaction with the underlying UI elements which is recorded.

Steps:

  • Open Automator
  • Start a new "Workflow"
  • Start recording
  • Perform whatever steps you require with your app (in this case typing into textedit)
  • Stop recording
  • This will create a list of actions in Automator like:

![enter image description here

  • Select all these and copy (CMD+c)
  • Open the Applescript Editor app
  • Paste (CMD+v). The result will be valid applescript to perform the actions you just recorded:

enter image description here

Note that as is generally the case with UI automation, the automator records steps exactly and the script plays them back exactly. This my not be exactly what you want - e.g. if a different application were active, the text could get typed in there instead. The generated applescript should be used as a guide to the final applescript.

like image 92
Digital Trauma Avatar answered Oct 10 '22 23:10

Digital Trauma


The problem is that applications need to explicitly support AppleScript recording in order for it to work, but almost no applications actually do. Finder still supports it a bit, and maybe a couple other apps (BBEdit comes to mind), but for the most part, AppleScript recording has been pretty useless for quite some time.

like image 32
Brian Webster Avatar answered Oct 10 '22 22:10

Brian Webster