Questions tagged [applescript]

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

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

Script that outputs number of emails in Mail.app inbox

I'd like to have a command-line script I can invoke at the Terminal that will output the total number of messages in my "Work" Inbox in mail.app. Usage would look like this: $ inbox-count 48 What ...
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.
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:...
3
votes
1answer
2k views

How to convert JSON to AppleScript properties

How can I get AppleScript to run this query and save each value (country, city, etc.) as an AppleScript variable? http://ip-api.com/json/8.8.8.8?fields=country,city,isp,org,as,mobile,proxy,message I'...
2
votes
3answers
12k views

Get components (path and filename) of POSIX filepath

Given: ~/Desktop/Foo.scpt contains: (POSIX path of (path to me)) as text Which returns: /Users/[username]/Desktop/Foo.scpt How do I get path /users/[username]/Desktop/ and the file name Foo....
2
votes
1answer
3k views

Can an AppleScript write to a Notes.app document?

I would like to write text to a "Note" (as opposed to a standard .txt or .rtf file), because Mac Notes automatically sync to an iCloud account, across devices. (I understand that one can use various ...
9
votes
1answer
956 views

What are the differences between Applescripts saved as *.scpt and *.applescript?

It seems to me that those scripts that are saved as *.applescript are always meant to be the raw, uncompiled text while those that are saved as *.scpt can be either the raw text or the compiled ...
8
votes
2answers
6k views

Automatically delete a folder daily

Is there a way to automatically have a folder deleted every day at 4am? I'm running 10.6.7.
6
votes
3answers
3k views

Emulating associative arrays in AppleScript

A problem that would be trivial to solve with key=>value pairs. For each item in list_a, find the matching item in list_b and compare a single attribute (calculate scale ratio for two sets of images). ...
6
votes
3answers
13k views

Applescript to retrieve account and password using keychain scripting

How can I use keychain scripting to write a script in Applescript that retrieves the login and password of a website from the login keychain, given the website's URL?
5
votes
2answers
4k views

Assistive Access when script is launched by agent

Problem Applescript run by osascript is not allowed Assistive Access when launched by agent (~/Library/LaunchAgents). Although it works when run from Applescript editor or commandline directly (using ...
4
votes
2answers
1k views

Is it possible to change a Finder List View column width in AppleScript?

I want to create an AppleScript that opens five predefined folders in five different tabs in one new Finder window with predefined bounds and then shifts the active tab of this window to tab one. I ...
3
votes
3answers
701 views

How preserve JPEG date stamps during Automator scaling?

Automator services embedded as a context menu are a great way to quickly scale down JPEGs in the finder. Right click the file, choose your scaling script, done in seconds. The problem is it ...
3
votes
1answer
4k views

Create playlists for full albums in iTunes (i.e. albums with all songs)

How could I create playlists for all of the albums in iTunes for which I have all of the songs? Assume that track number & track count metadata is accurate where specified, and don't worry about ...
2
votes
3answers
2k views

AppleScript alternatives

I've recently discovered AppleScript. AppleScript affords a simple, natural way to programmatically simulate keyboard-and-mouse interaction with Mac applications. AppleScript is great, however it ...
1
vote
5answers
14k views

How can I create a stand alone APP to run a terminal command

I have the requirement to manually run the OSX maintenance scripts in OSX (Lion / Mountain Lion). I would like to create a completely stand alone application that would achieve the following goals: ...
1
vote
1answer
717 views

Is it possible for an AppleScript .app file to retain its custom icon, even after edits have been made to the code?

I've created an AppleScript .app file in Script Debugger.app. I assigned a custom icon to this .app file by pasting a new icon over the default icon in the application's Get Info window in Finder. ...
9
votes
8answers
7k views

Sending push notification to iPhone via AppleScript

Is there any combination of iPhone and/or Mac apps that I can use to send a push notification to my iPhone? For example, let's say I want to create a service (invoked via (Application Name) > ...
7
votes
1answer
9k views

Where did “URL Access Scripting.app” go in Lion?

I have AppleScripts that run on a schedule to download files from URLs. They had been using URL Access Scripting.app's download event, which now looks to have disappeared from Lion. I can't find any ...
7
votes
2answers
2k views

Did Apple remove the “AppleScript handler” option in macOS High Sierra?

I wanted to make a little script involving messages on my Mac and after some research I discovered it was indeed possible. The only problem is that the "AppleScript handler" option in Messages>...
7
votes
3answers
9k views

How to disable individual USB ports by script?

I am looking for a script which will allow me to disable one specific USB port on my Mac mini. It would only serve a purpose if it works in real-time and didn't require a reboot. I've found scripts ...
6
votes
5answers
16k views

How to open a new Terminal tab in current working directory?

I want to create and run a bash function that: cd into a project's directory Open a new tab in Terminal in the same directory Open my dev tools and start dev services Item #2 doesn't work as ...
6
votes
2answers
23k views

How do I get Automator actions for Microsoft Powerpoint and Word?

I'm trying to set up Automator with a folder action to convert any Powerpoint or Word documents I drag into it to PDFs. I found this question: How do I script Powerpoint to save a directory of PPTX ...
6
votes
2answers
10k views

Automating ffmpeg using Automator Service

I often use ffmpeg off the command line to convert video files into mp4 on my Mac (running Mavericks). Do note, however, that I am NOT re-encoding my videos; am just changing the container from an avi ...
6
votes
1answer
15k 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 ...
5
votes
2answers
1k views

Is there a sane way to emulate the newer media key behavior completely on an Apple Extended Keyboard II?

The operative word here being "completely". I recently found a nearly flawless (cosmetically and functionally) AEKII (Alps, not Mitsumis) on eBay and won it for $30. It's an awesome keyboard and it ...
5
votes
0answers
2k views

AppleScript to read all notifications in the Notification Center OSX 10.10 Yosemite

It seems like the following AppleScript is no longer working in the latest version of the OS X 10.10 (Yosemite): on run tell application "System Events" tell process "Notification Center" ...
5
votes
4answers
3k views

Changing trackpad scroll direction with AppleScript in Yosemite

I prefer "natural" scroll direction when using my MBAir trackpad, but "unnatural" when using the mouse. I frequently switch back and forth depending on where I'm working, so I've been using a bit of ...
4
votes
2answers
755 views

Is there a definitive reference or introspection capability for Applescript?

Is there some canonical place I can find a reference for the scripting capabilities various things have in AppleScript? For instance, I'd like to automate iTunes a little bit. Looking around on the ...
4
votes
2answers
2k views

Applescript to click green (zoom) button with Option down

Based on Applescript - the activate command makes application "half-active", I wrote the following Applescript which would allow me to click the green (zoom) button at the top-left corner of ...
3
votes
1answer
3k views

Automator -> send file to email (from filename)

Im trying to create an Automator folder action that sends an email with an attached file. In my folder the files will be generated with the email as name: Example: name@company.com.jpg, othername@...
3
votes
2answers
2k views

AppleScript: How to double-click & right-click at cursor location?

I want to be able to double-left-click, then immediately right-click using AppleScript. The location of the click is wherever my cursor is located at the time that the AppleScript is triggered. The ...
3
votes
1answer
2k views

AppleScript UI Scripting and click

I would like to click and have automatic action with a software, I can refer to it and get the value of the text but can't manage to click tell application "System Events" to tell process "app" ...
3
votes
2answers
2k views

AppleScript - How to identify buttons and press them?

I'm trying to automate the running of techtools via AppleScript. I have got it working but only with full keyboard access (using tab and space to navigate the UI) but not all machines have this ...
3
votes
2answers
1k views

How to call a specific subroutine of an AppleScript from another AppleScript?

I understand that it is possible to trigger an .scpt file that is saved somewhere on my computer from within a different .scpt file. Can I call a specific subroutine of that .scpt file from a ...
3
votes
7answers
10k views

Mail.app in Lion - is there a way to create tasks from email?

I'm not sure if I haven't seen that in earlier versions of Mail.app, but I would really love to have the ability to create a task in iCal from an email - and that this task could link to the original ...
3
votes
2answers
1k views

How to use AppleScript in a bash script to create an alias for an app?

I need to create an alias on my Desktop to an app in my Applications folder, using a bash script file. As far as I know, it's only possible with AppleScript. Unfortunately, my AppleScript skills are ...
2
votes
2answers
571 views

Applescript to automatically add .noindex extension to a file?

I'm interested in excluding certain files from Spotlight, and it was suggested to add the .noindex extension. I'd like to automate this. How is it possible to do via Applescript?
2
votes
2answers
4k views

Script opens two terminal windows

I coded this little AppleScript using Automator: tell application "Terminal" do script "myscript" end tell This perfectly works but has a side effect: when I close the window, there's always the ...
2
votes
3answers
601 views

AppleScript bug: When placing plain text on the clipboard, the text is always converted to rich text

Run the following code to put some text on your clipboard: set testString to "This string should be plain text." set the clipboard to testString If you open up a new .rtf file in TextEdit.app, and ...
2
votes
2answers
19k views

Using Javascript | Applescript to click button in Safari

I realize there are several threads about this and they are all very specific to certain website . My background is in Python, not Javascript or Applescript, and I'm confused on exactly how to achieve ...
2
votes
1answer
196 views

Disable badge for specific app with a script

I know that I can turn on/off the badge from the notifcation center, but is there a way to do it with a script? If possible I would love to do for a specific app, otherwise it will be fun to turn it ...
2
votes
4answers
5k views

Applescript - Unable to find resource when inside application

I have a regular Applescript application bundle that executes an applescript file when it's run. I'm trying to run a shell file that is located at "/Contents/Resources/Data/df.sh", however with the ...
1
vote
3answers
2k views

AppleScript – How can I _get_ UI elements' names, attributes, properties, classes programmatically without “guessing” via AccessibilityInspector?

When I started to search for an AppleScript's generic way to "click onto Safari's context menu" of a selected item, there were a lot of questions on "how-to" on several levels of nomenclature. How ...
1
vote
1answer
1k views

Can I generate a clickable link to local file using relative path like “file:///~”

This is the background: in my company, we use Google Drive and often have to tell each other the path to a particular file. Paths are long as we use a lot of nested folders, so it's pretty boring and ...