Questions tagged [applescript]

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

Filter by
Sorted by
Tagged with
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.
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 ...
7
votes
4answers
4k views

Using Apple Script to Manage Sound Output Selection

I am brand new here and I have an additional clarification or need additional help for an issue from this thread - Applescript: "can't get tab group 1 of window" (El Capitan) In my ...
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} ...
8
votes
4answers
6k 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, *...
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 ...
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)?
0
votes
3answers
526 views

Applescript Won't Invoke Shortcut Command

I have a long TextEdit document I frequently open (via a keystroke, thanks to Alfred). It contains many non-standard spellings, so I de-select "Check Spelling While Typing" (though I want spell ...
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
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 ...
4
votes
1answer
2k views

How to rework a “System Events” command in AppleScript, so that it automatically works in all applications?

With the following AppleScript code within a "Run AppleScript" action in a Service: tell application "System Events" set theSBounds to {{572, 64}, {332, 515}} set position of window "Google ...
2
votes
3answers
8k 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 ...
6
votes
2answers
8k views

When MouseKeys are on, how do I click or move the mouse using AppleScript?

This post suggests that the command tell application “System Events” to key code 37 in AppleScript should move the mouse pointer one pixel down and to the left if run when MouseKeys are enabled. In OS ...
3
votes
1answer
2k views

Can't save AppleScript file when created by touch

I'm used to create file using touch before opening them with open. But I came to this following problem : When I do this with AppleScript files AppleScript Editor is able to open the file but unable ...
2
votes
1answer
804 views

Find specific attached disk, not volume, by Applescript

I have a script I use to format any inserted SD card, copy data from specific folders to it, then eject. Each format/copy is triggered manually, as part of a batch process involving maybe a hundred ...
2
votes
1answer
1k views

AppleScript Help: Wait for Safari Page to load

I am trying to create a script to open the URL csbsju.instructure.com in Safari, wait for the page to load all the way, click the login button, and then double check if the URL is correct (there's a ...
7
votes
2answers
12k views

Open terminal via AppleScript

I'm tring to write a shortcut script in spark for opening the terminal. on run {input, parameters} tell application "Utilities/Terminal" // tried Utilities:Terminal and Terminal too reopen ...
5
votes
1answer
3k views

Applescript: “can't get tab group 1 of window” (El Capitan)

The following is an applescript that I use to change audio output devices: tell application "System Preferences" activate set current pane to pane "com.apple.preference.sound" end tell tell ...
4
votes
2answers
3k views

Run script before restart/shutdown

Is it possible to execute a script/command right before OS X is shutting down or restarting? I'd like to run sudo apachectl stop to stop apache from auto-starting.
3
votes
1answer
3k views

ffmpeg working from command line in Terminal but not in an Automator shell script!

I have just compiled my own copy of ffmpeg on my system and it's located in the following path: /opt/local/bin/ffmpeg When I run the following command in Terminal.app, it runs smooth: ffmpeg -i /...
3
votes
2answers
697 views

How to create a blank RTF file in AppleScript?

I want to be able to create a new TextEdit document with an AppleScript file. The AppleScript file will then be triggered by a system-wide keyboard shortcut via FastScripts. Specifically, I want the ...
1
vote
1answer
754 views

Swap Mouse Button using AppleScript

I use mouse with left-hand. My system is shared with other people who are right handed. So, I need frequently to switch mouse button. I would like to know how to swap mouse button using AppleScript? ...
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..."...
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 "...
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 ...
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 ...
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, ...
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 ...
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 ...
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 ...
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 ...
5
votes
2answers
12k views

Can Applescript be used to automate a screen recording session on OS X?

I need to accomplish the following tasks from a script: Initiate a screen recording (with system audio). After a set delay, stop the recording. Save out to a file. Close the recording. I've tried a ...
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 ...
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?
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
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
1answer
780 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 ...
8
votes
4answers
2k views

Applescript run from menu bar?

I am aware of the Script Editor menu. That is not what I'm looking for. Is there a way to run an Applescript from the menu bar? I can save it as a file and run it from the Script Editor menu, and I ...
6
votes
3answers
5k views

Drag to convert Automator Action into Applescript

In Automator, there is a way to quickly convert an Action into its equivalent Applescript in Automator, I think by dragging it in some tricky way. I saw this some time ago but have now forgotten. I'...
2
votes
2answers
4k views

How can one invoke a keyboard shortcut from within an AppleScript?

I need to invoke a keyboard shortcut from within an AppleScript code, later to be used as a startup item (i.e. the alternative to having to press something at every log in).
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 ...
8
votes
3answers
2k views

Is there a way to have AppleScript output displayed in the menubar?

Before reading further: I know about butler and similar programs. I am looking for a BUILT-IN way to do this without a third party app. Anyway, I wrote an AppleScript that runs a shell command. I ...
4
votes
1answer
5k views

How to automatically connect VPN when connecting to a network?

In my university, the only way to access Internet is to connect to a VPN server. I've configured the VPN on my Mac and it's working fine, but I need to manually connect to the VPN every time I connect ...
3
votes
2answers
3k views

How to pass variables from bash script to AppleScript

I have a file with a list of URL's. I need to pass each URL from a bash script to be used in an AppleScript. while read urls do osascript -e \ 'tell application "Safari" tell ...
2
votes
1answer
2k views

AppleScript: How to open a link in Google Chrome in a new, adjacent tab?

The following AppleScript code will open the link in a new tab, at the location of the very end of the current tabs: set myLink to "https://www.google.com/" tell application "Google Chrome" ...
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 (...
5
votes
3answers
1k views

How to change volume of “say” in AppleScript?

Here is a line from my AppleScript that speaks the selected text: set this_say_Pid to do shell script "LANG=en_US.UTF-8 pbpaste -Prefer txt | say > /dev/null 2>&1 & echo $!" I would ...
5
votes
3answers
3k views

How to use AppleScript to create a new Rich Text Format file from clipboard text?

I have an Automator Service that takes the current text on the clipboard and writes it to a new .txt file. This is executed simply with the following piece of AppleScript code: do shell script "...
4
votes
1answer
2k views

System-Preferences Applescript using osascript cannot select its window

This AppleScript (based on an answer in a MacWorld form) will tell me whether or not Screen Sharing is enabled: tell application "System Preferences" reveal pane "com.apple.preferences.sharing" ...