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

learn more… | top users | synonyms (2)

74
votes
5answers
32k 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
38k 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 ...
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 ...
13
votes
3answers
7k views

How can I “say” to another Mac?

I have two Macs in our house (iMac and MacBook Pro). I would like to use the say command-line utility to type something on my MPB and have it speak on the iMac, rather like an intercom system. Plus, ...
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 ...
12
votes
6answers
10k views

How to set screen resolution with a keyboard shortcut on Retina MBP?

I've found myself switching between the 1440x900 and 1920x1200 "effective resolution" setting depending on what I'm doing (need more space on screen, etc). Is there a way to toggle between these two ...
11
votes
8answers
9k views

How to retrieve current wattage info on OS X?

Is there a way to retrieve the current watt usage info on OS X Snow Leopard? I'm using mid-2010 iMac, so I'm not looking for just battery-related apps. Does OS X even monitor power usage? Do I need ...
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)?
9
votes
4answers
3k views

AppleScript vs. Bash script?

I'm a long-time Windows "power user" and developer who has recently decided to move over to Mac OS X. On OS X Lion and indeed previous versions there seem to be two main options for scripting and ...
9
votes
4answers
17k views

How do I open Google Chrome in Incognito mode by default

Is there any way (using apple script or by using settings on chrome) to open Google Chrome in incognito mode.
9
votes
2answers
8k 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} ...
9
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, ...
9
votes
3answers
9k views

iCal No Longer Runs Scripts?

I have some automated tasks in the form of AppleScripts which I would schedule to run overnight via an iCal event. The event would simply be set to "run script" at "0 minutes before the event" and ...
9
votes
2answers
4k views

How to change AppleScript path to a Terminal-style path?

I have a custom Service that I've created in Automater (I'm on OSX 10.6.5). The Service executes an AppleScript which in turn executes a shell script. Here is the AppleScript: on run {input, ...
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 ...
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 ...
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.
8
votes
1answer
4k views

How do I find out the applescript commands available for a particular app?

I'm trying to find out if I can get iTunes to do something complex, but don't know what can be scripted. Is there a way to find out what applescript commands an app will respond to?
8
votes
3answers
1k views

How can I make an AppleScript activate upon logging in?

Is it possible to force an AppleScript to activate when I log in?
8
votes
2answers
232 views

How would I go about making a stand alone app on my dock to open a game using a terminal command?

I have a game that they never released for mac, and I installed the game using WINE, the install itself was flawless, but every time I want to play it, I'm forced to open Terminal and run cd ...
8
votes
4answers
800 views

Copying formatted text from a web page to an Applescript input dialog

I have an Applescript which - simplified - looks like this: ... display dialog "foo" default answer "" ... One of the users of this script runs Lion. Whenever he tries to copy/paste a string to the ...
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 ...
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 ...
7
votes
1answer
432 views

Simple auto-typer with AppleScript

I want to make a small application that will type the number 1, wait an interval, type the number 2, wait an interval, type number 3, wait an interval, etc. This works for typing one number over and ...
7
votes
6answers
3k views

Sending push notification to iPhone via AppleScript

Is there any combination of iPhone and/or Mac apps that I can use to send a push notification to my iPhone? For example, let's say I want to create a service (invoked via (Application Name) > ...
7
votes
2answers
5k views

How can I bring a window to frontmost without focusing it using Applescript in OS X 10.8

I want to bring a window (QuickTime for example) to frontmost, without focusing it. I can do it in OS X 10.7 using the following code in Applescript. tell application "System Events" set visible ...
7
votes
3answers
2k views

How to add folder to Spotlight “do not index”?

Is there any way to programmatically add a folder to Spotlight's "Privacy" tab? Either through Terminal or Applescript? Often I want to click on an item in Spotlight results in Finder, and have that ...
6
votes
3answers
1k views

look up a word in Dictionary.app in Terminal

Is there a bash or applescript to look up a word in /Applications/Dictionary.app from a Terminal window ? open -a /Applications/Dictionary.app/ --args word ignores --args, says "type a word to look ...
6
votes
3answers
3k views

Change the default application (for a file extension) via script/command line?

Is there a way to define the default application for a file extension via an Apple script, command line command (like defaults write [...]). I know that you can change it manually via the information ...
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 ...
6
votes
4answers
8k views

How do I make an AppleScript with a drop-down menu without Xcode?

How do I make an AppleScript that displays a drop-down menu without using Xcode?
6
votes
5answers
136 views

Scriptable menu bar icons

Is there an easy way I can add custom icons to the menu bar status area? Ideally something like Growl (e.g., where you can just execute a command) but instead of notifications, just renders icons in ...
6
votes
3answers
4k views

Script to raise a single window to the front

In a script I'm trying to find the Terminal.app window containing a specific tty device and raise that window to the top. Here's what I have in Applescript so far: tell application "System Events" ...
6
votes
2answers
526 views

What's the easiest way to automate logging into a website?

There's this website I need to access about every ten minutes. And apparently it was designed in 1993, by sadists. There is no "remember me on this computer" checkbox. And if you don't interact with ...
6
votes
1answer
324 views

Any way to get the “Open With…” list via AppleScript?

I want to create an AppleScript that gets the Finder selection and displays a list of applications that are capable of opening it. In other words, is there any way to get the list of apps that ...
6
votes
1answer
960 views

How can I update iTunes Match from the command line?

I use iTunes Match to access my iTunes library at work. I added some new music to my library (back at home) recently, but I forgot to run the "Update iTunes Match" command to ensure that the songs ...
6
votes
1answer
649 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 ...
6
votes
3answers
2k views

How to disable individual USB ports by script?

I am looking for a script which will allow me to disable one specific USB port on my Mac mini. It would only serve a purpose if it works in real-time and didn't require a reboot. I've found scripts ...
5
votes
1answer
2k views

Is there a way to force Mac OS X to close all the applications when restarting?

I sometimes shut down my Mac, and I cannot wait it shuts down because I am urgently requested to do something in another office that would require some hours. In some cases, an application that opens ...
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
3answers
357 views

How do I create a Folder Action Script to tar items dropped in folder?

I would like to drop/copy files/folders and have them compressed then copied to my desktop. This is what I know so far... and it isn't much so any help would be appreciated. on adding folder items to ...
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.
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
2k views

Is there a fast way to change proxy setting?

On my laptop I usually have a ssh connection open and use the remote machine as a proxy server just so that all my network traffic is over ssh. I know that it's hopeless and we're all doomed, but it ...
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, ...
5
votes
3answers
657 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
2answers
899 views

A programmatic method for disabling all sharing services?

I'm seeking a programmatic method for disabling all the sharing services on a Mac. My preference is for an AppleScript or a shell script. I'd like to have the services shown in the picture below ...
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, ...
5
votes
1answer
476 views

How can I use an Applescript from within a program?

This question Is there a way to add all of the recipients of an email to a group/folder in contacts from Mail? seems to have an answer that would be useful for me, but I don't actually know how to use ...
5
votes
2answers
2k 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 ...