Mac Os X Automator Search For Selected Text

Mac OS X Speciality level out of ten: 0 Apr 16, 2014 10:43 PM in response to Brian Smith5 In response to Brian Smith5 Thanks for that - now I will stop pounding my head trying to get it to work - trying various different locations and options.

Automator is an often overlooked utility that lets you build workflow assistants that can take repetitive tasks and automate them for you. Of course, you don't have to use Automator only for complex or advance workflows—sometimes you just want to automate a simple task like opening your favorite apps and documents.

You probably have specific work or play environments you use with your Mac. For instance, if you’re a graphic designer, you may always open Photoshop and Illustrator, plus a couple of graphics utilities. You may also keep some project folders open in the Finder. Likewise, if you're a photographer, you might always open Aperture and Photoshop, plus your favorite website for uploading images.

Of course, opening applications and folders is a simple process; a few clicks here, a few clicks there, and you're ready to work. However, because these are tasks you repeat over and over, they're good candidates for a bit of workflow automation.

In this step-by-step guide, we're going to show you how to use Apple’s Automator to built a program that will open your favorite applications—as well as any folders and web pages you frequently use—with just a single click.

What You Need

  • Automator: This app comes with your Mac. The instructions below are relevant for macOS High Sierra, but with a bit of tweaking, you can make it work for other versions of the Mac operating system, too.
  • Applications: Compile a list of the applications you want to open automatically when you launch the program you'll create with Automator.
  • Folders: If there are specific folders you work from on a regular basis, the application you create with Automator can open them in Finder windows.
of 03

Open Applications and Folders

  1. Open Automator, located at /Applications.
  2. Select Application in the window that pops up when you first open Automator. In some versions of Mac OS, you might need to first select New Document and then Application as the template type.
  3. Click the Choose button.
  4. In the Library list on the left of Automator, select Files & Folders.
  5. Locate Get Specified Finder Items in the middle panel and drag it to the panel on the right-hand side of Automator. You can also double-click it in place of dragging it.
  6. Click the Add... button to add an application or folder to the list of Finder items. Keep doing this until all the items you need for your workflow are present. Don't include your default browser (in my case, Safari) in the list of Finder items—we'll choose another workflow step to launch the browser to a specific URL.
  7. From the Library pane, drag the Open Finder Items to the workflow pane, below the previous action.

This completes the part of the workflow that opens applications and folders. To have your browser open a specific URL when you run your program, continue on with the next step.

Otherwise, to finish here, see the last section below on how to save and run the workflow.

Mac
of 03

Working With URLs in Automator

  1. In the Library pane, select Internet.
  2. Drag the Get Specified URLs action to the workflow panel, below the previous action. This action will include Apple's home page as a URL to open—select the Apple URL and click the Remove button (unless, of course, you want that URL to open in your program).
  3. Click the Add button to attach a new item to the URL list.
  4. Double-click in the text box for the URL to change the URL to the website you want to open when you run your program.

What Is Automator On Macbook

Repeat these steps for each additional URL you want to open automatically. When finished, return to the Library > Internet pane and drag Display Webpages to the workflow pane, just below the previous action.

of 03

Test, Save, and Use the Workflow

Automator

When you're finished creating your workflow, you can test it to make sure it actually functions correctly. To do this, click the Run button at the very top-right corner of Automator.

Because we're creating an application, Automator will issue a warning about how it won't receive input when running inside Automator. You can safely ignore this warning by clicking the OK button.

What Is Automator On Mac

Automator will run the workflow. Check to be sure that all of the applications opened, as well as any folders you may have included. If you wanted to open your browser to a specific page, make sure the correct page loaded.

What Is Automator App

Once you've confirmed that the workflow works as expected, you can save it as an application.

  1. Click the File menu in Automator and select Save...
  2. Enter a name and location for your workflow application and click Save.

With the .APP file created wherever you saved it, just double-click it to run the workflow. Because it works just like any other Mac application, you can also click and drag the workflow application to the Dock, or to a Finder window's sidebar or toolbar.

If you're on-the-go, you can create workflows in the iOS Workflow app for your iPhone, iPad or Apple Watch.

Active7 years, 4 months ago

I’m using nslater's wonderful script for counting words and characters in a selected block of text, but I need two enchancements:

  1. have the script available even without text selected. Currently, when I pull up the list of available Services without a selection, the Service isn’t there (that’s logical, of course, but enhancement #2 would change things).

  2. add a conditional behaviour to the script: if no text is selected, process all text, but if there is a selection, then only process the selected text.

Here is nslater's script, which I pasted into Automator (I created the Service by following the steps in his commented instructions):

RemielRemiel

1 Answer

The following AppleScript code will do what you are after:

Mac Os X Automator Search For Selected Text Background

Mac Os X Automator Search For Selected Text

If you want to use it in service, you will have to set that service to take “No Input” – as Ken Thomases correctly stated in his comment, services only process input if there is a selection. In the case of a “No Input” service, you are essentially creating a global (or app-specific, if you restrict the service to an application) launch point for a script. Any other script launcher that does not steal focus from the app it targets will serve as well (and might be faster – Automator services tend to be veeerrrrryyyyy sssllllooooowwww on first launch).

Automator Mac Download

Also note the whole thing works through the Accessibility API (the foundation for GUI scripting) and needs access to the API to be enabled by the user – either by checking “Enable Access for Assistive Devices” in the “Accessibility“ pane of System Preferences, or by doing

Mac Os X Automator Search For Selected Text Of Dropdown

it also requires the target application to support the Accessibility API in its text views as defined by Apple (see documentation linked to above), and do so correctly. MS Office applications, don’t, for one (they use non-standard views without selection attributes – thanks @adayzdone), and I wouldn’t be surprised if Adobe CS applications didn’t either. Java and AIR applications will probably be problematic, too.

Finally, while I‘m at the caveat empteor stage, I’ll add the speed of the script depends directly on the complexity of the UI hierarchy of the targeted application. This is not problem in the case of ordinary apps, but it is definitely in the case of WebKit generated web views – aka Safari and co. – as these map the whole DOM to UI elements. Although very laudable in terms of accessibility, this results in a humongous UI hierarchy which will take quite a time to traverse.

Mac Os X Automator Search For Selected Text Color

Community
kopischkekopischke
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Not the answer you're looking for? Browse other questions tagged textosx-lionapplescript or ask your own question.