AppleScript is the Mac OS scripting language.

learn more… | top users | synonyms

20
votes
3answers
16k 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 ...
6
votes
2answers
6k 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 ...
1
vote
3answers
1k views

How to bring application to front every 15 minutes on Mac OS X Lion?

I have a free or cheap little app called Desktop Task Timer LE that I've been using to track my time as I work on various projects. I'd like to have it pop up as the foreground app every 15 minutes to ...
3
votes
2answers
6k 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 ...
2
votes
1answer
3k views

How to open a new Firefox window with URL argument

I am trying to upgrade the existing answer How to open a new Firefox window with Terminal to accept a URL as an argument and open a NEW Firefox window. I can use open -a Firefox ...
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 ...
0
votes
2answers
364 views

Apple Script - Reopen Closed Finder Windows

I have the following Applescript which toggles the show/hide hidden files and I would like to reopen the user's Finder windows which will be closed as the Finder gets relaunched. tell application ...
0
votes
1answer
1k views

Change Mac “Ask for password after screensaver” delay

How can I change my Mac OS X Snow Leopard "Ask for password after screensaver" delay? I've tried: defaults -currentHost write com.apple.screensaver askForPasswordDelay -int 3600 but won't work. I ...
28
votes
6answers
28k 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 ...
2
votes
1answer
960 views

How to open a new Firefox window with Terminal

I am running Firefox v10.0.1 with OS X Lion v10.7.3 From the Apple dock, you can right-click on Firefox icon and choose NEW and a new Firefox window will open. From terminal, I have tried open ...
4
votes
2answers
3k 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" ...
2
votes
2answers
4k 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 ...
3
votes
4answers
2k 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

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
4k 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 ...
2
votes
1answer
719 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, ...
1
vote
1answer
1k views

Pass arguments to osascript via shell function in OS X Mountain Lion

The answer in How to open a new Firefox window with URL argument is broken in Mac OSX Mountain Lion (10.8.2). I can't comment on that answer or question, so I had to create a new question. It fails ...
1
vote
2answers
2k views

How to I use Apple Script to change the keyboard layout on Snow Leopard? [duplicate]

Possible Duplicate: Switch TO specific input source I want to do something like: set keyboard layout to 'QWERTY' or something like that.
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 ...
3
votes
1answer
697 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
3answers
4k 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
1
vote
2answers
3k views

Get path of sub-folder's Parent : Applescript

I want to get the path of a subfolder's parent folder when I drop a folder on a application coded in Applescript So if I drop a folder called 'Test1' which is on the Desktop I want the script to ...
1
vote
1answer
68 views

Is it possible to set a Custom quick look preview image in OS X?

Is there any way to set a custom quick look image in OS X? I'd like a command line tool or applescript to change or embed a custom preview for a zip file using a jpeg.
0
votes
2answers
115 views

Condition in AppleScript if directory doesn't contain extension recursively then quit app

This seems to work. The only problem is it is not recursive. property Location : alias "Macintosh HD:Location" tell application "System Events" to files of Location whose name extension = "ext" if ...
0
votes
2answers
1k views

Applescript to close box by hitting ok automatically

I need to create a script that automatically closes a popup box that opens approximately every 55 - 65 seconds. Once the box opens, you merely hit OK (within the box) and it closes. I created an ...
0
votes
1answer
315 views

Using AppleScript to Enable Snow Leopard's Text Replacement Feature

I currently use Quicksilver with a Plugin and Trigger in concert with Snow Leopard's text replacement feature (for frequently-used combinations of hashtags, due dates and other parameters) to quickly ...
0
votes
2answers
2k views

AppleScript and Preview.app

I saw this post: http://superuser.com/questions/155517/how-do-i-get-applescript-to-work-with-preview-in-snow-leopard In my attempt to figure out how to use AppleScript with Preview. I'm trying to ...
0
votes
1answer
2k views

How do I get applescript to work with Preview in Snow Leopard?

How do I get applescript to work with Preview in Snow Leopard? I'd like, for instance, my applescript for resizing a window to full screen (which works for most applications (e.g., chrome)) to work ...
-2
votes
2answers
104 views

Mac always restarting after reboot

I created an AppleScript to restart my Mac: tell application "System Events" restart end tell I put this script into Calendar.app and set it to start at 7.00. When I put script into calendar and ...