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

learn more… | top users | synonyms (2)

79
votes
5answers
35k 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 ...
19
votes
1answer
41k 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 ...
13
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 ...
10
votes
5answers
3k 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)?
5
votes
3answers
3k 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, ...
10
votes
2answers
9k views

Run AppleScript from bash script

If I wanted to run an AppleScript from within a bash script I could call a file with the list of commands that I require to execute. #!/bin/bash {some commands} osascript file.scpt {other commands} ...
3
votes
3answers
6k 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
943 views

System-Preferences Applescript using osascript cannot select its window

This AppleScript (based on an answer in a MacWorld form) will tell me whether or not Screen Sharing is enabled: tell application "System Preferences" reveal pane "com.apple.preferences.sharing" ...
0
votes
0answers
55 views

Run old applescript in automator

I want to use automator to extract text from mail. The applescript used to do that is an old version of the scripting language. My mac will accept only the latest. Is it possible that I can run the ...
3
votes
1answer
2k 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.
3
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 ...
2
votes
1answer
4k views

Why is my applescript for checking if a file exists failing?

I have an applescript application that inputs a username and starts a download based on that username. In the app I use the code below to check if a file exists already and then rename the file if it ...
9
votes
4answers
4k 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 ...
9
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
2answers
4k views

“Fetching…” Behavior in Finder “Open With” Menu in Yosemite

I don't know if other people have notice this in Yosemite: With a file in Finder in focus, when you move the cursor to "Open With" entry, whether from context menu or menu bar -> File, a ...
7
votes
4answers
9k 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
4answers
2k 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
2k 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 ...
4
votes
1answer
1k views

Toggling screensaver password with script

I am using a rather old application called Proximity to trigger applescripts when my phone goes in and out of bluetooth range of my mac. Along with other tasks, I want to secure my laptop when the ...
2
votes
1answer
315 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 ...
16
votes
2answers
3k 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 ...
6
votes
1answer
7k 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
2answers
836 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
750 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 ...
4
votes
2answers
518 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
676 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
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
2k 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 ...
9
votes
4answers
3k 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, ...
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 ...
6
votes
1answer
666 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
741 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
487 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
6answers
7k 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
641 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
128 views

How to close applications on sleep?

I have a password management application (KeePassX) of which backup I sync over Dropbox across several computers. However the password database can be open only on one computer at a time for file ...
3
votes
2answers
384 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
403 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
5answers
7k 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 ...
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
854 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
1k 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
2answers
582 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
2answers
50 views

Applescript to automatically add .noindex extension to a file?

I'm interested in excluding certain files from Spotlight, and it was suggested to add the .noindex extension. I'd like to automate this. How is it possible to do via Applescript?
1
vote
1answer
87 views

Apps Stuck in Security & Privacy > Accessibility

I was messing around with using AppleScript for GUI manipulation so the apps I was making had to be granted access. The very first one I did showed up in Security & Privacy > Accessibility as ...
1
vote
1answer
51 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 ...