AppleScript is a proprietary programming language in Mac OS X to control and exchange data with applications.

learn more… | top users | synonyms (2)

56
votes
4answers
25k views

How can I trigger a Notification Center notification from an AppleScript or shell script?

I'd love to be able to take advantage of 10.8's Notification Center features in AppleScripts and shell scripts I write. Is there a built-in command or a third-party library I can use from either an ...
18
votes
1answer
30k views

How do I automate a key press in AppleScript?

Is it possible to automate the key press of a key (such as "a" or "<") in Mozilla Firefox, Google Chrome or Safari (in this order)? I'd like to automate the key press of "a" for example in Mozilla ...
10
votes
5answers
2k views

How can I automatically launch an application whenever the Mac goes idle?

Is there a way to launch an application, such as Transmission, every time the computer goes idle (instead of sleeping)?
12
votes
7answers
2k views

Is there a bash command to check to see if Time Machine has finished backing up?

I'm writing a script that will rsycnc my Time Machine directory to a remote server using ssh. I've switched from a shell script to an AppleScript and then back to an Apple script and I don't really ...
3
votes
3answers
5k views

Applescript to retrieve account and password using keychain scripting

How can I use keychain scripting to write a script in Applescript that retrieves the login and password of a website from the login keychain, given the website's URL?
3
votes
1answer
1k views

Run AppleScript after waking from Sleep?

Is there an easy way to run an AppleScript or application immediately (or a brief delay of X seconds) after waking up from sleep? I'm looking for a solution that doesn't involve a 3rd-party app.
2
votes
2answers
4k views

When MouseKeys are on, how do I click or move the mouse using AppleScript?

This post suggests that the command tell application “System Events” to key code 37 in AppleScript should move the mouse pointer one pixel down and to the left if run when MouseKeys are enabled. In OS ...
9
votes
4answers
3k views

Creating an automated HFS+ compressed folder

I would like to set up an automated way for archiving files in OS X Lion. By archiving I mean using HFS+ compression feature on a specific folder, and make every file that I move into this folder ...
8
votes
1answer
2k views

Any way to set/add tags on a file with Applescript under Mavericks?

Trying to move some of my scripts over from labels to tags under Mavericks, but I can't seem to find a way to set/add tags with Applescript. Anybody that know how to do this? As far as I can figure ...
6
votes
4answers
8k views

How to know the name of UI elements using Accessibility inspector (or any other tool)

I'm trying to interact with a print dialog via Applescript. What I want to emulate is the user setting a value on a specific dropdown. Say I have: tell application "System Events" tell process ...
5
votes
3answers
2k views

Programmatically/Script-atically changing the default Open-With setting

Is there a way to change what app opens a file type programmatically/with a script? Basically, sometimes I'm working on a web site, and I want to set all web files to open with a text editor (*.php, ...
5
votes
4answers
1k views

Automatically quit Terminal when typing exit

Scenario I use terminal to SSH a lot, however would like the Terminal App to quit when the last Tab closes using exit. I already have the terminal window itself set to close on successful exit, ...
8
votes
2answers
3k views

Automatically delete a folder daily

Is there a way to automatically have a folder deleted every day at 4am? I'm running 10.6.7.
5
votes
1answer
1k views

Run Command Line Script from Finder's contextual menu

I have a shell script that deletes exif data from images. I would like to right-click the folder with the images and execute the command from the context menu. How can I do this? The Shell script ...
2
votes
1answer
277 views

Can I run a program whenever I open the lid of my MacBook Air? [duplicate]

Possible Duplicate: Run AppleScript after waking from Sleep? I have a program, InstantShot!, set to launch at logon and start taking a screen shot every 10 seconds. Unfortunately, when I ...
15
votes
2answers
2k views

How do I make an AppleScript file into a Mac App?

I have an Applescript that simply opens a Dialog Box, asks for a user input and runs a Terminal Command and spits out the answer. It works great in AppleScript Editor yet I am trying to work out how I ...
5
votes
2answers
764 views

Is there a way to have AppleScript output displayed in the menubar?

Before reading further: I know about butler and similar programs. I am looking for a BUILT-IN way to do this without a third party app. Anyway, I wrote an AppleScript that runs a shell command. I ...
4
votes
3answers
587 views

Is there a sane way to emulate the newer media key behavior completely on an Apple Extended Keyboard II?

The operative word here being "completely". I recently found a nearly flawless (cosmetically and functionally) AEKII (Alps, not Mitsumis) on eBay and won it for $30. It's an awesome keyboard and it ...
3
votes
2answers
449 views

Emulating associative arrays in AppleScript

A problem that would be trivial to solve with key=>value pairs. For each item in list_a, find the matching item in list_b and compare a single attribute (calculate scale ratio for two sets of images). ...
3
votes
2answers
399 views

Copy message_id from selected message

In Mail, when I've selected a message, I would like to have a shortcut to copy the message_id (see my previous question) to the clipboard. How do I manage that? Applescript, I presume?
3
votes
2answers
2k views

Any way to trigger Folder Action when adding file to any subfolder?

I've created a Folder Action in Automator and applied it to a folder. But it only gets triggered when a file is added to the root of that folder, not to one of its subfolders. Is there any way to get ...
1
vote
3answers
833 views

Using automator and handbrake cli to convert videos automatically

I am trying to automate video conversion process using Automator and Handbrake CLI version. I am trying to implement the functionality that whenever a video is downloaded in my dropbox folder on my PC ...
8
votes
3answers
1k views

Copying files to the clipboard using applescript

Often I find myself at the command line wanting to copy files to the clipboard, so that I can paste them as attachments in Mail. If I have an image file, image1.png, I can accomplish this with ...
8
votes
4answers
2k views

OS X right click/context menu via keyboard

Is it possible to access the right click/context menu of the currently selected item (not the item under the mouse) by way of using a keyboard shortcut? If not, is there any way to achieve this, ...
6
votes
1answer
582 views

Toggle Finder sort order with AppleScript under Lion 10.7?

For years I've been using this AppleScript to toggle the sort order of a Finder window: if sort direction of column id size column of list view options of window 1 is normal then set sort ...
5
votes
3answers
428 views

“drag n drop” application to convert images to base64 string (for web development)

I'm after an osx program that will convert an image into a base64 string (for web development). Basically replicates this: http://webcodertools.com/imagetobase64converter/Create I suspect there is ...
5
votes
1answer
400 views

Execute a custom script when OS X 10.8 is in Power nap?

Apple new feature of OS X 10.8 in new Macs "Power Nap" checks email and does make backups. Is it possible to execute a custom script (bash, AppleScript,...) when OS X 10.8 is in Power nap mode? For ...
5
votes
3answers
5k views

Activating screen saver from AppleScript in Mountain Lion

I had a script that I used to use to activate my screen saver, and it no longer works in Mountain Lion. It was a shell script that called an AppleScript script: #!/bin/bash osascript ...
5
votes
1answer
6k views

Where did “URL Access Scripting.app” go in Lion?

I have AppleScripts that run on a schedule to download files from URLs. They had been using URL Access Scripting.app's download event, which now looks to have disappeared from Lion. I can't find any ...
5
votes
6answers
6k views

How to run Applescript on Disk mount

I want to run an Applescript when I mount a specific disk. It isn't if the script is located on the disk or not, it should just run when OS X mounts the disk. I tried to accomplish this with folder ...
5
votes
2answers
3k views

Is it possible to restart an application using AppleScript?

I want to restart Safari and reopen it with some tabs that I specify.
4
votes
1answer
604 views

How can I automatically download multiple sites through Coda?

I have several sites in Coda that I would like to automatically re-download when I tell it to. The sites are collaboratively managed, and I'd like to download a fresh copy of the sites automatically. ...
3
votes
2answers
329 views

Is there a definitive reference or introspection capability for Applescript?

Is there some canonical place I can find a reference for the scripting capabilities various things have in AppleScript? For instance, I'd like to automate iTunes a little bit. Looking around on the ...
3
votes
3answers
360 views

How can I have a fixed order of the menu-extras?

Like the OSX menu items for wifi, battery... I would like to be able to have a permanent order of the third-party menu bar items. I do not want to mix OSX with third-party menubar items, I simply ...
3
votes
6answers
9k views

Mail.app in Lion - is there a way to create tasks from email?

I'm not sure if I haven't seen that in earlier versions of Mail.app, but I would really love to have the ability to create a task in iCal from an email - and that this task could link to the original ...
3
votes
2answers
1k views

Is it possible to disconnect a bluetooth connection using Applescript?

I want to disconnect a connection to a bluetooth device through an Applescript. Please note that I don't want to disable or enable bluetooth, I just want to disable one specific connection.
2
votes
2answers
536 views

How to swap command and option modifier keys with a script in OS X Lion

I use a PC usb keyboard with my macbook. So, I've gone into System Preferences > Keyboard > Modifier Keys... and swapped command and option for the usb keyboard. This puts those keys in the ...
2
votes
1answer
941 views

Why won't my AppleScript run as a Service?

I have a simple AppleScript that works exactly as expected when run on its own, ether as an app, directly from within ScriptDebugger or Script Editor, or as an element of an Automation from within ...
2
votes
5answers
6k views

How can I write a script to open multiple terminal tabs and execute code in them?

I want to be able to open the terminal application and have it either automatically run a script that opens several tabs and run an arbitrary set of commands in each. For example I would like one tab ...
2
votes
2answers
528 views

How can one invoke a keyboard shortcut from within an AppleScript?

I need to invoke a keyboard shortcut from within an AppleScript code, later to be used as a startup item (i.e. the alternative to having to press something at every log in).
1
vote
1answer
43 views

Can I give Automator apps a window?

Can I create a window / UI for applications created using Automator? Or is this just not possible with Automator apps? Background: I created an "application" through Automator, and dragged the app ...
1
vote
2answers
514 views

Applescript dictionary for Preview

Is there an Applescript dictionary for Preview.app? I am unable to find it under Mac OS X 10.7.5, and Applescript 2.2.1. I did a rudimentary search in google and duckduck but came up empty. I've ...
1
vote
1answer
455 views

using automator/applescript to upload files to a web form?

I have a bunch of files I want to upload to web page. Unfortunately the web form for uploading only allows me to specify one at a time (it spawns and 'open file' dialog). Is there an easy way to do ...
1
vote
2answers
1k views

Automate PDF actions

To improve my paperless workflow, I'm looking to achieve the following, potentially using automator / applescript. I need to be able to run it using Hazel, or as a folder action (not run manually): ...
1
vote
1answer
1k views

Automator workflow or AppleScript to close Safari after a period of time

I would like to create an Automator workflow (or some similar function) that will close down Safari after a specified period of time. For instance, I simply want to run Pandora in Safari during the ...
1
vote
2answers
714 views

Run an AppleScript by using a keyboard shortcut

I need to run an AppleScript using a keyboard shortcut. How can I do that? I think about Save AppleScript in textual format. Use Keyboard Maestro to launch 'osascript' to run the script when the ...
0
votes
1answer
5k views

Automatically Save Attachments in Mail.app in 10.8 Mountain Lion

I am trying to automatically save all email sent to one address (let's call it test@example.com) to this folder /Users/luomat/Dropbox/Incoming/e2w/ (where /Users/luomat = $HOME). Here is the rule ...
5
votes
1answer
394 views

How can I find the intersection of two lists in AppleScript?

Let's say I have two lists in AppleScript: set listA to {"red", "green", "blue"} set listB to {"green", "blue"} I'd like to create a third list that has only the items present in both lists: set ...
4
votes
2answers
513 views

Where can I access official AppleScript documentation?

Is there any official AppleScript documentation? If so, where can I find it?
3
votes
2answers
95 views

Cleaning up birth years 2000 in my Address Book

A few years ago (or actually, more likely, in 2000), for some reason, birthdays that didn't have a birth year (but did and do have correct month and day) were automatically given the birth year 2000 ...