AppleScript is the Mac OS scripting language.

learn more… | top users | synonyms

28
votes
6answers
27k views

How to find my stolen Macbook

A friend of mine just had her Macbook stolen. Her Dropbox account is still working on the Macbook, so she can see each time the Macbook comes online, and she can get its IP address. She has given ...
16
votes
2answers
12k views

Assign a shortcut to running a script in OS X

Does OS X provide an easy way to bind key combinations to commands which are typically run on the command line? For example, is there some way to assign ⌘ Cmd+L as a global shortcut for ...
13
votes
5answers
46k views

Track kids browsing history even when they know how to clear it manually

I have a colleague with two teenage boys (yes, cue cliche's about 'I have this friend see...') He's currently having issues with them browsing pr0n and wants to do a little spying on their browsing ...
9
votes
2answers
420 views

Prettier text dialogs in OS X scripts

I'm getting pretty sick of these default AppleScript and cocoaDialog dialogs: I'd like to replace them with something closer to this: Has anyone made a shell executable like cocoaDialog with a ...
8
votes
7answers
3k views

MacOS X: How to have a handy “Open this folder in iTerm” shortcut?

I think the title states exactly what I want to do. I want a shortcut or even a button within Finder which fires up a new iTerm Tab and changes the location to the location i've open in Finder. Some ...
7
votes
2answers
4k views

Applescript to open a NEW terminal window in current space

Yes, I'm having a terrible newbie experience with Apple Script. I need to open a new Terminal window in the current desktop space. NOT move me to another space which has a Terminal running and then ...
7
votes
1answer
646 views

OS X Lion Inverted Scrolling Automation Shortcut

As everyone will know (who has Mac OS X Lion), by default, scrolling is inverted to make it a bit like the iPhone. Problem: There is no way to have "normal scrolling" for a USB mouse, and ...
6
votes
2answers
5k views

How do I set up an AppleScript to open a new iTerm2 tab and change the directory?

In OS X, how do I set up an AppleScript to open a new iTerm2 tab change to a directory clear the console echo the current directory I had something like this before for regular Terminal, but I ...
6
votes
1answer
2k views

Automated Interaction with Google Chrome

All right SU, I have a fun nut to crack. I have 8 screens set up in a line, all hooked into one beefy G5 running Snow Leopard (yes, 4 graphics cards; about 15,000 pixels wide!). I am setting up a ...
5
votes
5answers
2k views

Apple Mail: Flag message from keyboard

One of the flags in Apple Mail can be applied to a message using Command-Shift-L. Is there a way to apply any other flag? I renamed one of the colors to TODO, and I set up a keyboard shortcut for ...
5
votes
2answers
4k views

Make AppleScript wait for an Application to finish loading

I have an applescript to initiate my work environment, but have a small quibble with it. I want the script to launch several programs, and then hide them, once they started. The code looks like this ...
5
votes
1answer
2k views

Programmatically set the color of a tab in iTerm2?

My daily workflow includes me Launching iTerm2 Creating 3 tabs Setting one tab each to red, orange and yellow Changing to a specific path in each tab I would like to script this process; shell, ...
5
votes
2answers
1k views

How do I make Mail.app quit after iCal sends an alert?

iCal uses a built in script file to email reminders through Mail.app. It works great, but I don't use Mail.app for my main email account, just for sending calendar notifications. So, Mail.app opens ...
5
votes
1answer
800 views

Determine Mac's screen state using AppleScript

Is there a way to determine what state the Mac's screen is in? I'd like to have a script that checks if the screen is in a non-active state; so either the screen saver is running or the display is ...
5
votes
1answer
787 views

Responding to Growl notifications with Applescript

I'm looking to write some Applescript which is run in response to Growl events. e.g. email arrives from a given user which effects some change on my Nabaztag. I can find plenty on the internet ...
5
votes
1answer
1k views

Folder actions on OS X observing all subfolders

I have a folder that I would like to add a folder action to. The action works great when the file is added to the top level. But when a file is added to and sub-folders, the action is not enabled. Is ...
4
votes
1answer
2k views

Identify Mac OS X Window, Group, and Text Field names for use in AppleScript

I have an Applescript in which I wish to set the value of the text fields Name and Password of a window belonging to the process SecurityAgent. It is similar to the following: tell window ...
4
votes
1answer
493 views

Mail.app: Showing remote images automatically for specific senders

In a similar way to what gmail allows, I'd like to get specific senders' remote images to be auto-loaded. One option that I came across is using a rule and an applescript: ...
4
votes
1answer
393 views

Way to switch F keys to 'application' keys and back on mac via terminal? (10.6)

Is there a command I can issue via terminal to switch my F1-12 keys to being application keys (media, screen brightness ...) and back? i.e. replicate toggling System Preferences => Keyboard => ...
4
votes
5answers
2k views

How to prevent iTunes from adding converted Mp3s to the library?

When I use iTunes to create Mp3 files from songs I've bought, iTunes also adds them to my library and I got them twice. How can I prevent iTunes from adding converted Mp3s to the library in the first ...
4
votes
3answers
673 views

Logout user script

I am trying to create a script in ARD that will let me logout a user. Now I have a script which does start the logout, but I want it to execute instead of waiting 60 seconds. The script currently ...
4
votes
1answer
2k views

Creating “save as” functionality to .eml file in AppleScript

I'm new to AppleScript and trying to figure out how to save a Mail.app message as an .eml message. Ideally, I would like it to act similar to the Mail menu bar actions, in which it saves the message ...
4
votes
2answers
1k views

Mac Screenshot of a Specific Window without Using the Mouse/Click

I've been researching for a day or two but can't find a method to take a screenshot of a specific window (possibly the only window) open at a specific time using an Apple script. Currently I have the ...
3
votes
3answers
1k views

How do you duplicate current open Finder view in new tab (Mavericks)?

In a thread on this forum there is an interesting solution on how to open a duplicate of an already open Finder window with the help of an AppleScript: How do you duplicate current open Finder view? ...
3
votes
3answers
3k views

Switch between Google Chrome Tabs using AppleScript

I was hoping that the following code would do the job, but no cigar: --Only the window is brought into focus tell application "Google Chrome" activate tab 1 of window 1 end tell
3
votes
3answers
3k views

Automatic PDF renaming based on title

I have thousands of scientific PDFs that i need to rename, many do not have metadata. I would like to be able to create an automator action that could open a folder then open each PDF, copy the title ...
3
votes
4answers
3k views

Applescript to lock the screen

I need a little Applescript to lock the screen, the same behaviour I get when I click the Keychain icon in the menu bar and choose "Lock screen". I found a way to activate the screensaver, but it's ...
3
votes
2answers
308 views

Change the OSX system language in a script

Manually I just go into the system preferences, change the language ordering, and restart my app so it starts up in the default system language. Then I can run automated tests with the app running in ...
3
votes
1answer
1k views

How can I run a script whenever I plug in an external monitor? [duplicate]

Possible Duplicate: Reset Mac OS X Windows Position after de-attaching external monitor I use my laptop at work, where I have a second monitor, and at home, where I don't. When I plug in ...
3
votes
1answer
1k views

What is the best way to make Calculate SHA1 as a context menu option in Mac OS X?

In order to calculate the SHA1 checksum of a downloaded file, I could type /usr/bin/openssl sha1 in Terminal and then drag there the file which I want check. To make it simpler, one could enable a ...
3
votes
3answers
1k views

How to update Mac OS X Mavericks desktop background from a script

How can I update Mac OS X Mavericks desktop background from a script? Update Mac OS X desktop background from a script worked up to OS X 10.8, but doesn't work anymore. The desktop defaults to the ...
3
votes
3answers
1k views

Quotes within quotes applescript

I am doing an applescript that is supposed to set an command with quotes an varible. This is the code so far: set myString to "This is a "quoted" text." But an error occurs because applescript ...
3
votes
5answers
7k views

Toggle “ask for password after screensaver/sleep” or the delay in 10.7 using terminal

There's an option in the preference panel to change the time the mac is able to be in sleep/screensaver before requiring a password to be unlocked again. I'm using OS X Lion 10.7. Is there any way ...
3
votes
1answer
516 views

AppleScript Editor record doesn't work

I have opened the AppleScript Editor and pressed Record button. Then I run TextEdit, create a file and put some text there. When I click Stop button in AppleScript Editor, nothing was recorded, the ...
3
votes
1answer
2k views

How do I close a window from an application, passing the file name?

I’m trying to produce an Applescript-based shell command that tells the Preview application from Mac OS X to close a particular window. #!/bin/sh osascript <<EOF tell application "Preview" ...
3
votes
1answer
391 views

iCal AppleScript, how to specify 'the same day at 9'?

I know that I can define a new iCal event programmatically, by means of AppleScript, defining something like: tell application "iCal" tell calendar "My Calendar" set theCurrentDate to ...
3
votes
2answers
5k views

How do I automate clicking a button in an application's window with AppleScript?

Let's say I want to click a button that appears somewhere within a window, using AppleScript. click button works, but you have to know which button exactly you want to press. For example: Scanning ...
3
votes
1answer
960 views

Selective Play/Pause VLC and iTunes with AppleScript

I have 5 button mouse, and i currently using one button for play/pause the music in iTunes (with USB Overdrive app). But sometimes i'm using VLC (i don't want scre up my music library with lot of ...
3
votes
1answer
943 views

How do you send the “ESC” key in OS X using osascript

I'd like to create a small script using osascript in Mac OS X Snow Leopard to emulate pressing the Escape key on the keyboard. How is this most easily done?
3
votes
1answer
205 views

AppleScript based Automator service quite unstable (sometimes very slow, sometimes encounter error)

I have some applescript based Automator services, for instance, Launch Emacs With Selected File: tell application "Finder" set selectedDirectory to (quoted form of POSIX path of (target of window ...
3
votes
0answers
536 views

Applescript to connect to bluetooth device

I'm trying to create an applescript to allow me to connect to a bluetooth device by it's Bluetooth ID. So far, i've managed to get an applescript to turn on bluetooth if it's off. Here's the code: ...
3
votes
1answer
1k views

Applescript create event in calendar, how do I remove the default alert?

Running 10.8 Mountain Lion, I'm trying to create a new event with Applescript like this: set theDate to (current date) tell application "Calendar" tell calendar "Calendar" set timeString ...
3
votes
1answer
198 views

auto-create symlink to currently inserted DVD

Is it possible to use applescript or a shell script to automatically create a reference to the currently inserted DVD? If I pop out Midsomer Murders DVD and insert Star Trek, the Wrath of Khan, the ...
3
votes
1answer
601 views

How can I run an AppleScript or shell command on Mac OS X at screen unlock?

Note that this is not the same as startup or login. I never log out of my machine and I want to run the script whenever I unlock the machine to start working.
3
votes
0answers
289 views

iTerm2: How to get output of a shell command with applescript

I want to get the output of a shell command run through iTerm2's applescript into an applescript variable. I tried the following but it does not work: tell application "iTerm" activate try ...
3
votes
1answer
244 views

Script Editor in Snow Leopard painfully slow after adding apps to Library

I have four different Macs that I use from time to time, and on each of them I notice a constant: adding more items to AppleScript Editor's Library window slows performance of mundane operations ...
2
votes
2answers
3k views

How do I run an Automator action, shell script or AppleScript on startup in OS X?

I know you can run applications on startup on a Mac, but can you run an Automator action, a Service, a shell script, or an AppleScript on startup instead? I also know you can save all of these as an ...
2
votes
1answer
971 views

AppleScript: Open a new window in current space without switching to active window in another space

I want to have an application open a new window in the current space without switching to a space in which a window is already open, but I want to keep the When switching to an application, ...
2
votes
1answer
597 views

Get path of open file in any application on Mac OS X?

I installed Afloat for Mac OS X and I really like that it has a shortcut to "Reveal Current File in Finder". This works for basically all applications written in Cocoa. Can I use something like that, ...
2
votes
1answer
585 views

Can you resize all mac windows at once? (e.g. when docking)

I've recently bought a Henge Dock, and like the ability to plug my MacBook in and instantly reconnect to all my peripherals (external monitor, keyboard, mouse, etc.). The only problem is that when I ...