Questions tagged [applescript]

AppleScript is a proprietary programming language in macOS to control and exchange data with applications.

Filter by
Sorted by
Tagged with
296
votes
11answers
168k 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 ...
80
votes
1answer
163k 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 ...
54
votes
2answers
60k 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} ...
50
votes
1answer
26k 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?
42
votes
3answers
26k 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 "Fetching..."...
40
votes
5answers
33k views

How do I assign a keyboard shortcut to an AppleScript I wrote?

How do I assign a keyboard shortcut to an AppleScript? I found a script for automatically going back to the inbox in Office 2011.
25
votes
8answers
11k 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, ...
22
votes
4answers
18k 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 ...
21
votes
12answers
35k 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 ...
20
votes
4answers
17k views

Mojave: disable or control the “[SOME_APP_NAME] wants access to control [ANOTHER_APP_NAME (often Finder)] …”?

A new security feature in Mojave revolves around a system dialogue that prompts you to grant access to apps that want to control other apps, such as Finder (I'm finding frequently happening with some ...
19
votes
9answers
10k 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 ...
19
votes
3answers
21k 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 MBP and have it speak on the iMac, rather like an intercom system. Plus, ...
19
votes
4answers
35k 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 "...
18
votes
6answers
33k 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.
18
votes
1answer
25k views

How do I focus a specific window with applescript without doing an activate and bringing other windows to the front?

I'm looking for a method w/ AppleScript to select/focus a specific window of an application without actually doing an "activate" which brings all windows to the front. Here's what I have so far: ...
17
votes
3answers
45k views

How can I remove a portion of from the middle of a movie?

Quicktime Player help: With QuickTime Player you can quickly remove a portion of the beginning or end of a movie or a movie clip to make it shorter or remove unwanted content. I want to remove ...
16
votes
7answers
5k 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 ...
16
votes
2answers
9k views

How to pause YouTube video via keyboard shortcut or from menu bar?

Is there a piece of software that allows one to pause (& un-pause) a currently playing YouTube video (or, ideally, any online video/audio media), with a keyboard shortcut or a conveniently ...
16
votes
4answers
7k views

How to programatically 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 ...
16
votes
4answers
8k 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 ...
16
votes
3answers
4k views

Is it possible to disable Safari extensions when using Private browsing?

I recently switched from Chrome to Safari for a few choice web applications, and I found that I couldn't disable extensions like Lastpass when browsing privately, at least not apparently, like I could ...
15
votes
3answers
6k views

Why are Script Editor .scpt files not saved as plain text files?

The Script Editor (formerly AppleScript Editor pre-Yosemite 10.10) saves .scpt files as binary files, not plain text files. It makes working with them in source code control systems somewhat ...
15
votes
5answers
6k 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)?
15
votes
6answers
19k 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 ...
14
votes
1answer
26k views

Select a menu item in AppleScript without using “System Events” in 10.9 Mavericks

I was just answering another question and was reminded of a new "feature" in Mavericks. I used to have a number of small Automator Services that took no input but did something useful when tied to a ...
13
votes
2answers
12k views

List of (activated) fonts with shell command in os x

Is there any shell command for getting a list of activated fonts? Something like: some_font_util -activated -format 'file: name' for getting a list of activated fonts in a form like: /Library/...
13
votes
3answers
16k views

How do I collect all of my notes and highlights from iBooks?

I've got a lot of highlighting and notes in iBooks that I've read, and would like to be able to collect them in one easy to use and manipulate format (e.g for writing papers and citing quotes). For ...
13
votes
1answer
3k views

What's the equivalent of “do shell script” with javascript automations? (Yosemite)

Support for javascript automations started with Yosemite. How could I run using javascript an external command? (i.e. the equivalent of do shell script of applescript?
12
votes
4answers
8k 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 ...
12
votes
4answers
29k views

Turn Wifi off/on with a single key?

Is there a way to assign the WiFi on/off function to one of the function keys like F4 that I otherwise never use? I assume Applescript would be required. However I may want to use a BASH script ...
12
votes
3answers
10k views

Run a program/script when the screen is locked or unlocked

Is there a way to run a specified script or program when the screen is locked or unlocked? Ideally a bash function or an AppleScript. Is there an event that I could subscribe to that would allow me ...
12
votes
3answers
14k 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 I'...
12
votes
2answers
12k views

Change the icon of an applescript-called notification

With OSX Mavericks we now can make notifications with applescript pretty easily. However, there doesn’t seem to be a way to change the icon that appears to a custom one. Is there a way to accomplish ...
12
votes
3answers
9k views

osascript is not allowed assistive access. (-1728)

Script: #!/usr/bin/osascript tell application "System Preferences" activate set current pane to pane "com.apple.preferences.users" delay 2 tell application "System Events" ...
12
votes
2answers
10k views

Automator app with a menubar icon

I've created an application with Automator. I want to have a new icon in the menubar like this: Which starts the app when I click on it. Is it possible? (without using Xcode) PS: I don't want a ...
11
votes
3answers
16k views

Problem with empty spaces when executing shell commands in AppleScript

The following code to purge a directory recursively does not work because I cannot get past the Application Support folder. try do shell script "rm -r ~/Library/Application\ Support/Google/Chrome/...
11
votes
2answers
13k views

macOS Sierra: AppleScript mount volume keeps asking for login

For several OS X versions I've used: /usr/bin/osascript -e mount volume "smb://yourserver" as user name "yourusername" with password “yourpassword” This has worked great, a nice and quiet mount of ...
11
votes
2answers
23k views

How can I configure my computer to run an AppleScript at a specific time? Caveat: without using iCal

Since upgrading to Lion, I have seen a sleight decrease of productivity when it comes to using iCal. As a result, I am trying alternatives such as BusyCal. The application seems great, however I cant ...
11
votes
2answers
11k 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 OS X 10.6.5). The Service executes an AppleScript which in turn executes a shell script. Here is the AppleScript: on run {input, ...
11
votes
1answer
30k views

How do I click a button using AppleScript?

I'm trying to press a button in TeamSpeak using applescript, here is my code: tell application "TeamSpeak 3 Client" to activate tell application "System Events" tell process "TeamSpeak 3" ...
11
votes
3answers
4k 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 ...
10
votes
6answers
13k views

Using AppleScript to lock screen

I need an applescript which locks my Mac in the same way pressing shift+ctrl+eject would. I tried two different approaches, but both failed. The first one was to search the internet for a script, ...
10
votes
6answers
14k views

How to create an OSX Application to wrap a call to a shell script?

My goal is to include in a zip file what amounts to a shortcut, instead of telling my customer(s) to open up Terminal and run a shell script. My deployable essentially looks like this: $ unzip ...
10
votes
6answers
16k 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 ...
10
votes
7answers
22k views

AppleScript “delay” command not working since switch to Yosemite

Note: The issue with delay was fixed in OS X 10.11 El Capitan. Ever since I upgraded to Yosemite, Applescripts that use delays have stopped working. How can I fix this? Here's the world's simplest ...
10
votes
2answers
31k views

AppleScript/Automate Mail Tasks

I've been trying to help a coworker automate a weekly email compilation he sends out but haven't yet been able to figure out how address a few specific areas...first I'll explain the situation, then ...
10
votes
1answer
783 views

Can I access internal microphone input level via Terminal?

I am interested in using my old MacBook as an audio baby monitor. My imagined workflow is to set a noise threshold for the internal microphone in the MacBook when baby is stirring or whining and to ...
10
votes
1answer
13k views

Applescript: Comparing variable to string is failing

I have an applescript that gets a list of items and then iterates over them: tell application "GeekTool Helper" set names to name of geeklets repeat with currentName in names if (...
10
votes
2answers
6k views

Automate taking a screenshot of specified area

I am trying to use automator to take a screen shot of a specified area. Though I can only find the option of taking a screenshot of a windows or the entire screen. Is there a option to to this with ...
10
votes
4answers
11k views

Create a command to focus a specific window from anywhere in OS

While developing for the web I tend to jump back and forth between my text editor and the browser a lot. I'd like to set a keyboard shortcut at the OS level that allows me to jump to a specific, ...