Questions tagged [applescript]
AppleScript is a proprietary programming language in macOS to control and exchange data with applications.
3,449
questions
410
votes
13
answers
250k
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 ...
119
votes
1
answer
250k
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 ...
102
votes
8
answers
113k
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.
86
votes
2
answers
40k
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?
78
votes
2
answers
93k
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}
...
62
votes
4
answers
133k
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 ...
44
votes
3
answers
27k
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..."...
36
votes
16
answers
79k
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 to ...
33
votes
7
answers
22k
views
Change display arrangement in OS X/macOS programmatically
I periodically have to move my display around (physically1) and this requires also rearranging my display arrangement in System Preferences. Manually doing this all the time is a pain in the neck. ...
31
votes
13
answers
16k
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 ...
31
votes
5
answers
15k
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 ...
29
votes
4
answers
26k
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 ...
28
votes
8
answers
15k
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, ...
27
votes
4
answers
26k
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"
...
26
votes
3
answers
29k
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/...
26
votes
5
answers
46k
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 "...
25
votes
8
answers
22k
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 ...
25
votes
1
answer
35k
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:
...
24
votes
3
answers
34k
views
How do I write a script that opens an iTerm2 window and runs a command?
What I'm doing
I'm using iTerm2 Build 3.0.15 and writing a script that opens a new window and prints "hello world" to the screen. Really, I'm interested in being to run any command but using echo "...
23
votes
6
answers
27k
views
Any way to change sound output device via Applescript or shell?
I would like to change sound output device (like option-clicking the speaker icon in the menubar) via script, but NOT through UI scripting, e.g., launching the System Pref panel.
UPDATE: Using @...
23
votes
5
answers
32k
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 ...
23
votes
3
answers
7k
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 ...
22
votes
11
answers
35k
views
Is it possible to change display resolution with a keyboard shortcut?
I use different screen resolutions based on the activity I'm doing during the day.
For example when I'm coding I prefer to have more space available.
Is it possible to associate a keyboard shortcut to ...
21
votes
5
answers
45k
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 ...
21
votes
5
answers
30k
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 ...
21
votes
1
answer
20k
views
When writing AppleScript in Automator, what is the significance of "input" and "parameters"?
When one adds a "Run AppleScript" action to a file in Automator.app (e.g., a workflow, application, or service), the following default code is presented:
on run {input, parameters}
(* Your ...
21
votes
2
answers
14k
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 ...
20
votes
5
answers
49k
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.
19
votes
3
answers
23k
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
3
answers
9k
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 ...
19
votes
1
answer
39k
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 ...
18
votes
7
answers
7k
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 ...
18
votes
4
answers
27k
views
Show Results of Automator-Terminal command
TL;DR If I create a .app via Automator, how can I show results of a shell script in a dialog or terminal window?
I am using Automator to run a shell script
adb install /Directory/$1.apk
and if I ...
18
votes
1
answer
48k
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"
...
18
votes
2
answers
16k
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 ...
18
votes
3
answers
2k
views
Set "Load remote content in messages" per sender?
In the Mail setting (under Viewing) tab, there is a option Load remote content in messages which I unchecked, so for each email that contains remote content, I need to click the Load remote content ...
17
votes
4
answers
24k
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, ...
17
votes
5
answers
7k
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)?
17
votes
4
answers
9k
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
3
answers
23k
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/...
16
votes
2
answers
16k
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 ...
16
votes
7
answers
22k
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 ...
16
votes
1
answer
5k
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?
16
votes
3
answers
12k
views
Edit TCC.db to bypass "'Foo.app' wants access to control 'Bar.app'" on own machine
I make extensive use of Apple Events to control a wide variety of applications on my machine. The new security prompts introduced in Mojave are crippling.
In previous versions of macOS, once an app ...
15
votes
2
answers
32k
views
Batch compress multiple folders into individual zip files
I have dozens of folders that I need to compress into individual zip files.
If I select all of these folders in the Finder and do "Compress [X] Items," I get one zip file containing all of the ...
15
votes
2
answers
22k
views
Set size of window to exact pixels, and place via x, y coordinates
I would like to create a tool that allows you to set windows to exact sizes on the pixel scale to be able to have more precise screen divisions.
For example, if I had four Terminal windows (and I ...
15
votes
3
answers
9k
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 ...
15
votes
1
answer
19k
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 (...
14
votes
7
answers
19k
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, ...
14
votes
2
answers
25k
views
Get Current Path to Script within AppleScript and Append Subdirectory
I have an AppleScript that I would like to be able to use from anywhere in the file system. Currently, it has some paths which are hardcoded, so it runs only from the Downloads folder. How should I ...