Easy Scripting For Os X
OS X Mavericks offers a pair of technologies — AppleScript and Automator — that make it easy to automate repetitive actions on your Mac.
His long-suffering wife brought a Mac home in 1984, which marked the start of Tom’s enthusiasm for the only OS for people who want to get work done. He’s ordered the Mac around in Basic, Forth, C, Pascal, and about a billion or so scripting languages.
AppleScript is “programming for the rest of us.” It can record and play back things that you, such as opening an application or clicking a button. You can use it to record a script for tasks that you often perform, and then have your Mac perform those tasks for you later. You can write your own AppleScripts, use those that come with your Mac, or download others from the web.
Automator is “programming without writing code.” With Automator, you string together prefabricated activities (known as actions) to automate repetitive or scheduled tasks. How cool is that?
Basics of AppleScript in OS X Mavericks
Describing AppleScript to a Mac beginner is a bit like three blind men describing an elephant. One man might describe it as the Macintosh’s built-in automation tool. Another might describe it as an interesting but often-overlooked piece of enabling technology.
The third might liken it to a cassette recorder, recording and playing back your actions at the keyboard. A fourth (if there were a fourth in the story) would assure you that it looked like computer code written in a high-level language.
They would all be correct. AppleScript, a built-in Mac automation tool, is a little-known (at least until recently) enabling technology that works like a cassette recorder for programs that support AppleScript recording. And scripts do look like computer programs.
AppleScript is a time-and-effort enhancer. If you just spend the time and effort it takes to understand it, using AppleScript can save you oodles of time and effort down the road. This stuff is far from simple; entire books have been written on the subject. Still, it’s worth finding out about if you’d like to script repetitive actions for future use. To get you started, here are a few quick tips:
You can put frequently used AppleScripts in the Dock or on your Desktop for easy access.
Apple provides a script menu extra that you can install on your menu bar in AppleScript Utility’s Preferences window — along with a number of free scripts to automate common tasks, many of which are in the Example Scripts folder. (An alias to that folder is present in the AppleScript folder.) Furthermore, you can always download additional scripts here.
Many AppleScripts are designed for use in the toolbar of Finder windows, where you can drag and drop items onto them quickly and easily.
Scripts can enhance your use of many apps including iTunes, iPhoto, and the Finder, to name a few.
AppleScript Editor (in the Utilities folder inside the Applications folder) is the application you use to view and edit AppleScriptsJust record a series of actions you want to repeat and use AppleScript Editor to save what you recorded as a script. If you save your script as an application (by choosing Format→Application in the Save sheet), you can run that script by double-clicking its icon.
If the concept of scripting intrigues you, open the Scripts (in the root-level Library) folder. Rummage through this folder and when you find a script that looks interesting, double-click it to launch the AppleScript Editor program, where you can examine it more closely.
Basics of Automator in OS X Mavericks
Automator does just what you’d expect: It enables you to automate many common tasks on your Mac. If it sounds a little like AppleScript to you, you’re not mistaken; the two have a common goal. But this tool (introduced in OS X Tiger) is a lot simpler to use, albeit somewhat less flexible, than AppleScript.
For example, in AppleScript, you can have conditionals (“if this is true, do that; otherwise do something else”), but Automator is purely sequential (“take this, do that, then do the next thing, and then . . .”).
Google drive for mac os mojave. Access all of your Google Drive content directly from your Mac or PC, without using up disk space. Learn more Download Backup and Sync for Mac Download Backup and Sync for Windows.
The big difference is that conditionals allow AppleScripts to take actions involving decision-making and iteration (“while this is true, do these things”); Automator workflows can’t make decisions or iterate.
The upsides to Automator are that you don’t have to know anything about programming and you don’t have to type any archaic code. Instead, if you understand the process you want to automate, you can just drag and drop Automator’s prefab Actions into place and build a workflow (Automator’s name for a series of Actions).
Computers do only what you tell them to do, although they can do it faster and more precisely than you can. But all computers run on the GIGO principle — garbage in/garbage out — so if your instructions are flawed, you’re almost certain to get flawed results.
When you launch the Automator application, you see the window and sheet. Choose one of the starting points if you want Automator to assist you in constructing a new workflow, or choose Workflow to start building a workflow from scratch.
Let’s use Service for the sake of this demonstration.
The Library window on the left contains all the applications Automator knows about that have Actions defined for them. Select an application in the top part of the Library window, and its related actions appear below it.
When you select an action, the pane at the bottom of the Library window explains what that Action does, what input it expects, and what result it produces. Just drag Actions from the Action list into the window on the right to build your workflow.
Automator is a very useful addition to OS X; it’s deep, powerful, and expandable, yet relatively easy to use and master. Do yourself a favor, and spend some time experimenting with ways Automator can save you time and keystrokes. You won’t regret it.
For additional information about AppleScript, Automator, Services, and much more, click here.
LaunchPad is the OS X Lion version of the old Launcher, or the iOS home screen, according to how you look at these things. A few notes on issues I’ve seen with LaunchPad. First, I’ve had to nuke LaunchPad and have it rebuild. To do so, delete the database.rm ~/Library/Application Support/Dock/*.db
You might also need to kill the dock:killall Dock
In a deployment scenario, I’ve started doing both as post flight tasks. Getting to the point where you’re granularly adding and removing items is done by editing the .db file in ~/Library/Application Support/Dock. In here is a generatedID followed by .db that makes up a SQLite database. This database can be managed using a number of SQLite management tools, such as Base or SQLite Inspector.The management of databases from within these tools is pretty straight forward. You browse the apps, locate the offending rule and delete it. Then killall on the Dock (shown earlier) to actually have it disappear. You can also use the sqlite3 command line (where the string that begins with BF is the generated ID of the database):sqlite3 ~/Library/Application Support/Dock/BF222CEA-E6B2-4804-BAA2-DED0428E6C90.db 'select * from apps'
Assuming you see a row in the output that you’d just love to get rid of, you can look at the bundleID and then get rid of it using a command like this:sqlite3 ~/Library/Application Support/Dock/BF222CEA-E6B2-4804-BAA2-DED0428E6C90.db 'DELETE from apps WHERE bundleid LIKE 'org.videolan.vlc'
Easy Scripting For Os X 11
Don’t forget to kill the Dock afterwards. That’s basically it. If you install an app and then want to toss items from Launchpad as a post flight use the bundleID, run sqlite3 and then a second query to verify that the item is gone. As you don’t know the generatedID for the database name, you can also replace it with * in scripts:Easy Scripting For Os X 10
sqlite3 ~/Library/Application Support/Dock/*.db 'DELETE from apps WHERE bundleid LIKE 'com.microsoft.uploadcenter'