Questions tagged [applescript]

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

Filter by
Sorted by
Tagged with
4
votes
1answer
3k views

Run AppleScript after waking from Sleep?

Is there an easy way to run an AppleScript or application immediately (or a brief delay of X seconds) after waking up from sleep? I'm looking for a solution that doesn't involve a 3rd-party app.
3
votes
2answers
3k views

How to swap command and option modifier keys with a script in OS X Lion

I use a PC usb keyboard with my macbook. So, I've gone into System Preferences > Keyboard > Modifier Keys... and swapped command and option for the usb keyboard. This puts those keys in the "...
3
votes
1answer
3k views

Pass a variable (folder pathway) to AppleScript in Automator

I am trying to pass a variable that has been set in Automator to an AppleScript within Automator. My Automator workflow is as follows: Ask for Finder Items (only allowing folder type) Set Value of ...
2
votes
2answers
2k views

How to change filepath structure using automator (windows to mac)?

I use a mac at work and people send me windows file paths all day. Does anyone know how to convert the filepath using applescript in an automator so I can right click in an email and then open it? ...
2
votes
1answer
2k views

Script to delete all groups in contacts

I would like to have a script to delete all my groups in my Contacts. Somehow I got a kind of replication bug resulting in over 500 groups. Delete them one by one is not an option. Tried this script, ...
2
votes
2answers
2k views

How can I automatically run an AppleScript on shutdown or logout?

I am more used to the Javascript style event handlers, but is there a similar thing in applescript that listens to system events like logout or shutdown to execute code or is there a way to have an ...
1
vote
1answer
757 views

I suddenly cannot open any files in Script Editor.app

Today, I was working on an .scpt file in Script Editor.app, when, suddenly, Script Editor would not allow me to save the file. It was a seemingly random occurrence; I had not done something unique ...
1
vote
2answers
1k views

Run an AppleScript by using a keyboard shortcut

I need to run an AppleScript using a keyboard shortcut. How can I do that? I think about Save AppleScript in textual format. Use Keyboard Maestro to launch 'osascript' to run the script when the ...
1
vote
5answers
1k views

How to prepend to text file in AppleScript?

I have a .txt file saved on my computer. I want Automator to add a bit of text to the very top of the .txt file. I do not want any text in the .txt file to be overwritten. I also want a new line to be ...
1
vote
1answer
291 views

When using a third-party script library, I can no longer save an AppleScript file in Script Editor.app

I have an AppleScript .scpt file that uses the Dialog Toolkit scripting library: Dialog Toolkit is an ASObjC-based script library for showing enhanced dialogs. The following line is at the top of ...
0
votes
3answers
4k views

change screen resolution with AppleScript

How can I change change screen resolution using AppleScript? If AppleScript can't do it, what about Terminal? I tried with examples at How to set screen resolution with a keyboard shortcut on Retina ...
0
votes
1answer
405 views

Download entire iTunes purchase history as CSV file (MacOS High Sierra)

Has anyone found a way to download iTunes Purchase history into some type of csv or text format? The closest thing I could find was this StackExchange answer of a great applescript that could ...
6
votes
1answer
10k views

Waiting until a window exists in Applescript?

I'm trying to work with the script below and the repeat until exists window "Print"loop never returns true (I never hear the beep 3). Is this the correct way to wait for a window to appear? I am ...
3
votes
1answer
3k views

Save attachments from Mail.app based on subject

I have been trying to write an Applescript to help me saving attachments, but realized quickly that I do not have the knowledge to do such a difficult script. Here is some background. We receive ...
3
votes
2answers
2k views

How to get color of pixel in coordinates 123, 456 in screen?

My AppleScript app needs to get color of pixel in coordinates 123, 456 in screen.
3
votes
3answers
2k views

Shortcut to eject all external hard drives but not MobileBackups

So far I've been using the following AppleScript to eject all external drives at once conveniently using a shortcut: tell application "Finder" eject (every disk) end tell This script is is ...
2
votes
1answer
2k views

Open a URL in Chrome Canary as incognito

I am currently using this Automator AppleScript to create a service to open a URL using Chrome Canary in incognito mode on run {input} set theURL to input if application "Google Chrome Canary"...
2
votes
1answer
903 views

Bash Script which calls osascript stops working when run by launchd

I am trying to troubleshoot a problem with a bash script that gets called by launchd. Here's a quick summary Calling the script manually by itself works fine with no errors. Within the bash ...
2
votes
2answers
821 views

Use caps-lock to lock fn key or other way to lock fn key?

What I want to achieve is simple: caps lock on = fn locked (use function keys). caps lock off = fn unlock (use media keys). I found a couple of topics around this problem, but their solutions didn't ...
2
votes
1answer
219 views

Applescript/Javascript to click submenu item of Jupiter Notebook in Safari

When I run a.ipynb jupyter notebook file in Safari, it opens at local host http://localhost:8888/notebooks/a.ipynb#. NOTE: The script should work for any *.ipynb file, a.ipynb is just an example. ...
1
vote
1answer
106 views

Copy file from Terminal and paste in Mail

I would like to copy a file to the clipboard in terminal (as a reference like Finder does it) and then when writing an email, paste it into Mail as an attachment (CMD + V). I posted an example ...
0
votes
2answers
596 views

Applescript with get every file loop fails

I want to run a script on all files with two specific extensions on a disk with a hierarchy of multiple nested folders. My script works fine when I choose a folder further down the line with fewer ...
0
votes
1answer
1k views

App made in Applescript Icon wont change

The app's Icon wont change for me I tried copying in contents as "applet.icns" I tried Copy + Paste in get info nothing will work I found a article on the internet about this problem they say that you ...
0
votes
2answers
108 views

Change installed AppleScript version

Is there any way to change the installed version of AppleScript? After mistakenly identifying my version of AppleScript as 1.0 by using a 15 year old script (turns out that just checks the version of ...
-1
votes
3answers
724 views

How to delete a specific line of a paragraph in AppleScript, while retaining the original format of the text?

I have a text variable of class text that shows something like this when it is returned: " This is sentence 1. This is sentence 2. This is sentence 3. This is sentence 4." I want to be able to ...
55
votes
1answer
27k 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?
20
votes
4answers
20k 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 ...
18
votes
6answers
34k 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.
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 ...
9
votes
2answers
5k views

Any way to set/add tags on a file with Applescript under Mavericks?

Trying to move some of my scripts over from labels to tags under Mavericks, but I can't seem to find a way to set/add tags with Applescript. Anybody that know how to do this? As far as I can figure ...
17
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 ...
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 ...
9
votes
2answers
16k 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 ...
7
votes
3answers
2k views

Copy message_id from selected message

In Mail, when I've selected a message, I would like to have a shortcut to copy the message_id (see my previous question) to the clipboard. How do I manage that? Applescript, I presume?
14
votes
2answers
13k 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/...
14
votes
3answers
11k 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 ...
8
votes
1answer
6k views

How to get the selected text into an AppleScript, without copying the text to the clipboard?

I've researched methods on how to get the selection as a text variable in an AppleScript. But these methods rely on copying the selection to the clipboard (for example, by keystroking the copy command ...
6
votes
4answers
2k views

Is it possible to keystroke special characters in AppleScript?

The Bug: For certain special characters and symbols, AppleScript will fail to keystroke the actual character, and will instead simply type the letter a. An Example: The following AppleScript code: ...
6
votes
2answers
5k views

Open a new Safari window in the current Space from Terminal with multiple tabs (URLs)

How to open an new Safari window from Terminal in the current Space? Now when using the open http://example.com command it opened the URL as last tab on my first Safari window. I'm looking for a way ...
5
votes
4answers
3k views

Automatically quit Terminal when typing exit

Scenario I use terminal to SSH a lot, however would like the Terminal App to quit when the last Tab closes using exit. I already have the terminal window itself set to close on successful exit, ...
18
votes
1answer
26k 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: ...
12
votes
1answer
31k 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
3k 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 ...
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 ...
8
votes
4answers
27k views

How do I create an AppleScript that will quit an application at a specific time and then put the computer to sleep?

I've been toying around with AppleScript and Automator to get this thing to work, but I just can't seem wrap my head around it. If anyone could show me an example or give me some tips on how I can set ...
8
votes
6answers
20k views

How can I write a script to open multiple terminal tabs and execute code in them?

I want to be able to open the terminal application and have it either automatically run a script that opens several tabs and run an arbitrary set of commands in each. For example I would like one tab ...
8
votes
4answers
4k views

Change display arrangement in OS X 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. ...
7
votes
3answers
3k views

Right-click for Creating a New Document - How?

I am comfortable with creating new documents from command line on OS X (in my case El Capitan), but I wanted to explore the possibility to have Windows-like option to create a new document on right ...
6
votes
1answer
3k views

Run Command Line Script from Finder's contextual menu

I have a shell script that deletes exif data from images. I would like to right-click the folder with the images and execute the command from the context menu. How can I do this? The Shell script is:...
6
votes
3answers
3k views

Is it possible to disconnect a bluetooth connection using Applescript?

I want to disconnect a connection to a bluetooth device through an Applescript. Please note that I don't want to disable or enable bluetooth, I just want to disable one specific connection.