TUAW Post > Preparing Blog Images with Automator

Automator's the perfect tool for streamlining some of the repetitive things you do on a daily basis. One thing it's great at is doing basic manipulation to lots of image files. Need to resize a bunch of images or convert them from one format to another? No problem, Automator is ready to help. In this post, you'll build an Automator workflow that prepares images for your blog by renaming them sequentially and then scaling them down in size. Don't have a blog? Well, this workflow could also be used for preparing images for insertion into a Word document, or to send in an email. Feel free to adjust to your specific needs.

[Read more on TUAW...]

MacTech Article > Introduction to AppleScriptObjC (Cocoa-AppleScript)

AppleScriptObjC, also known as Cocoa-AppleScript, is a framework in OS X. It was initially released with OS X 10.6, and serves as the official replacement for AppleScript Studio, which Apple deprecated at the time. AppleScriptObjC is used by scripters to write rich, fully featured Cocoa apps in AppleScript. Think of AppleScriptObjC as the “Pro” version of AppleScript. For building simple scripts, AppleScript alone works great. For building advanced and complex scripts, perhaps with advanced interfaces, you want to think about moving to AppleScriptObjC.

If you’re a hardcore AppleScript developer or regular MacTech reader, then you’ve probably heard of AppleScriptObjC. You may have worked your way through a tutorial, and maybe even created a very simple app. If you haven’t used AppleScriptObjC yet, then you may have used Xcode in the past to develop AppleScript Studio apps. This month’s column starts with the basics. It provides a very introductory look at AppleScriptObjC. While we won’t build an actual app just yet, we’ll explore some of AppleScriptObjC’s core concepts and syntax.

[Read the full article in MacTech magazine's Fall 2012 Special issue, available in print and in the MacTech iPad Newsstand app]

TUAW Post > Cascade Finder windows with AppleScript

You're busy. You've got tons of things going on at any given time. Your Mac's screen is constantly cluttered with a bazillion Finder windows, and you keep shuffling them around to find the one you need. Sure, Mission Control in Mountain Lion lets you view all of your Finder windows at once in a pretty tiled view. But, it doesn't sort them, and with a ton of little windows, finding the one you want is no piece of cake. How nice would it be if the Finder had a "Cascade Windows" feature? With a little help from AppleScript, your wait is over. In this post, you'll write a simple AppleScript that sorts your opened Finder windows and cascades them, making it quick and easy to find the one you want and clearing your cluttered screen in the process.

[Read more on TUAW...]

TUAW Post > Create Evernote 5 template notebooks with AppleScript

Evernote 5 is a wonderful app for gathering information and keeping it organized and synchronized between your devices. In Evernote, you create notebooks and fill them with notes. These notes can be anything - thoughts, web clippings, files, photos, audio, etc. Whenever you need to recall information you've added to Evernote, just type in a few keywords to instantly locate it.

This post shows how to use AppleScript to create template notebooks that contain default template notes. You can use these templates for creating new projects, jobs, or anything else you might need.

[Read more on TUAW...]

 

Macworld > Ask the Script Doctor: Working with Text

Ask the Script Doctor is a regular column in which we solve real-world Mac problems using AppleScript and Automator. If you have a problem you’d like us to solve, send an email to the Script Doctor for consideration.

Whether we’re writing novels or email, we all use text all the time. AppleScript is a great tool for making text-focused work easier and more efficient. For that reason, I get a lot of questions about how to simplify common text tasks. Here are a few of those questions and my answers.

[Read more at Macworld.com, subscribe to the print edition, or get Macworld on your iPad...]

Do you have a scripting problem or a question for the Script Doctor? Send it to scriptdoctor@macworld.com.

MacTech Article > Understanding AppleScript Dictionaries

Over the years, I’ve written dozens of AppleScript articles for MacTech.  Check the archives, and you’ll find my introductory articles on scripting various applications, error protection, looping, branching logic, and much more.  One topic that has somehow eluded my column is AppleScript dictionaries.  Since dictionaries continue to be a source of confusion for many scripters (trust me, I receive questions about them all the time), I’d like to take this opportunity to try to clear the air.

[Read the full article in MacTech magazine's August 2012 issue, available in print and in the MacTech iPad Newsstand app]

Peachpit Article > Building a Basic AppleScriptObjC (Cocoa-AppleScript) Application with Xcode

In OS X Mountain Lion, AppleScript continues to be a powerhouse tool for controlling applications on the Mac. Whether you need to automate the creation of a few folders in the Finder, or generate a several-hundred-page product catalog in Adobe InDesign, AppleScript is waiting to lend a hand. Despite AppleScript's learning curve, Mac users everywhere are using it on a daily basis, and it saves time and money that might otherwise be wasted.

 AppleScripts aren't known for having slick interfaces. Perhaps most often, these scripts are written as simple applications, using the AppleScript Editor (found in/Applications/Utilities). When you double-click the application, it launches, performs some series of hidden tasks, and then quits. Developing script applications that work like this is quick and easy if you have the know-how, but if you're planning to distribute your script to other people, this format isn't always ideal. For one thing, aside from displaying simple dialog messages, you have no real way to let users know what your script is doing. Furthermore, unless users are AppleScript-savvy, there's no way for them to adjust the behavior of your script.

AppleScriptObjC (also called Cocoa-AppleScript) is an advanced method of developing AppleScript-based native Cocoa applications. With AppleScriptObjC, you can develop rich user interfaces and interact with them directly from your scripts. [Read more on the Peachpit.com...]

Developer Tip > Saving Mail Attachments via AppleScript Fixed in Lion 10.7.2

If you use AppleScripts that interact with Mail in Mac OS X (such as Mail to FileMaker Importer), you may have noticed that when Lion was introduced, the ability to save attachments through scripting no longer worked.  This issue affected AppleScripts, as well as Automator workflows (Apple's own Get Attachments from Mail Messages Automator action was broken too).  Well, I'm pleased to say that this issue has been resolved in Mac OS X 10.7.2.  AppleScripts can now save Mail attachments again.

If you'd like to learn more about AppleScripting Mail, check out my MacTech column... Introduction to Scripting Mail.

Attention Outlook Users: Saving attachments via AppleScript did not work in Outlook either until a recent Office update.  If your Outlook scripts are failing when attempting to save attachments, make sure you update your Office 2011 installation to the latest version.  While I don't have an article available at this time for scripting Outlook, you can learn about scripting Entourage in my MacTech column... Introduction to Scripting Microsoft Entourage.  The AppleScript terminology hasn't changed too much between Entourage and Outlook, so some of it may still apply.

GUI Automation Tools for Mac OS X

I've received a lot of inquiries recently from people who are interested in controlling Mac OS X's GUI. First, let me say that there are some limitations inherent to most GUI automation processes. Here are the top five that I see most often...

  1. GUI automation is interface-reliant. It expects the interface to always be the same. If it changes, the process must be updated.
  2. GUI automation can sometimes be error prone. For example, changing the window layering on screen, accidentally clicking the mouse, and so forth, can cause some GUI automation tools to become confused.
  3. Tracking down the cause of a GUI automation error or problem is not always straightforward. Locating "button 12" of "window 500", for example, isn't as easy as it sounds.
  4. GUI automation tools typically have a limited ability to perform branching, i.e. looking at something, and making a decision about how to proceed.
  5. While GUI automation tools may be able to click around, select menus, and type keystrokes, they aren't good for "processing" actual data. For example, don't expect GUI automation to retrieve content from a database, bring it into an InDesign document, construct a catalog, output it to PDF, and send it to your printer.

For simple tasks, GUI automation may work just fine. For complex tasks, it may not. In these situations, you may need something much more robust, such as AppleScript, or AppleScript+GUI automation, or some other tool.

So, strictly with regard to GUI automation, there are a number of tools that can help you get the job done…

Automator - Automator has the ability to record manual tasks, and play them back as part of a workflow. Here are some resources I've released in the past to get you started…

Third-Party Automator Actions - My Automator Extension Action Pack includes several GUI automation actions, including:

  • Click Safari Web Form Button
  • Click Safari Web Form Checkbox
  • Click Safari Web Form Radio Button
  • Set Safari Web Form Text or Popup Field
  • Type Keystroke

Learn more or download a demo of my Automator actions here.

QuicKeys - An automation tool that can simulate user interaction by clicking buttons, selecting menus, and more. Essentially, a macro utility. Learn more on the QuicKeys website and in the following episode of my podcast...

iKey - Another macro utility for Mac OS X, allowing you to automate keystrokes, mouse clicks, and more. Learn more on the iKey website and in the following episode of my podcast...

Sikuli - An interesting visual automation tool for Mac OS X, which works from screenshots. Learn more on the Project Sikuli website.

Fake - A browser for automating web tasks, such as filling out forms, testing websites, and more. Learn more on the Fake.app website.

Eggplant - A visual, screen-shot-based automated testing tool, designed for automating processes across multiple machines (even PCs) through VPN. Learn more on the Eggplant website.

AppleScript Editor - Used to write AppleScripts, but also includes the ability to record manual tasks in certain applications as a script for later playback. Unfortunately, recordable applications are few and far between, but some include BBEdit, Fetch, and the Mac OS X Finder. Learn more in the following episode of my podcast...

If you are into AppleScript, check out my MacTech column on User Interface Scripting.

Accessing Properties of URLs with AppleScript

I recently stumbled upon the fact that a string can be coerced to a URL in AppleScript. This is cool because it allows you to access various properties of the URL, including the dotted decimal form of the URL's host.

"http://www.apple.com" as URL
--> {class:URL, scheme:http URL, path:"http://www.apple.com", host:{class:Internet address, DNS form:"www.apple.com", port:80, dotted decimal form:"23.0.29.15"}}

It should be noted that this isn't actually core AppleScript terminology. The "URL" class is terminology from the StandardAdditions scripting addition, which is included with Mac OS X.