Questions tagged [applescript]

AppleScript is an end user scripting language that has been available in Mac computers since System 7 Pro (7.1.1). It allows for automation of system tasks, communication between processes, and creation of workflows, amongst other functions.

AppleScript is a inter-application scripting language, designed to control and exchange data between scriptable applications. Users can use AppleScript to combine the functionality of multiple scriptable Mac applications to form a new application to meet their special need or demand without "reinventing the wheel".

Resources

8740 questions
30
votes
4 answers

"is not allowed for assistive access" error when running AppleScript from Java

I have a Jenkins config that executes Java tests for OS X app using Maven. And when I'm trying to run some AppleScript that requires assistive access for it, different errors appear. So I've tried to execute AppleScript in two ways: Using…
Kirill Aleksandrov
  • 326
  • 1
  • 3
  • 8
30
votes
7 answers

Can you execute an Applescript script from a Swift Application

I have a simple AppleScript that sends an email. How can I call it from within a Swift application? (I wasn't able to find the answer via Google.)
codingguy3000
  • 2,695
  • 15
  • 46
  • 74
29
votes
5 answers

How to tell an Applescript to stop executing

Applescript's "choose from list" user interaction has a "cancel" button — I want this "cancel" to tell the script to immediately stop executing. In other words: set wmColor to choose from list {"Black", "Black for all", "White", "White for…
jefflovejapan
  • 2,047
  • 3
  • 20
  • 34
27
votes
15 answers

Applescript fails with error (-600) when launched over ssh on Mavericks

I've tried searching for this, and have seen others with similar problems but don't seem to have found an answer anywhere.... I have an AppleScript that I am trying to run over ssh so that I can remotely control my mac. This has worked previously…
John Martin
  • 1,502
  • 1
  • 14
  • 25
26
votes
2 answers

QR Code generation in shell / mac terminal

I want to create QR codes for a project I'm working on in applescript the resulting qr will be placed in the indesign document. I have found that there is a plugin for indesign but I suspect that requires user interaction. So I've been search for…
mcgrailm
  • 17,469
  • 22
  • 83
  • 129
26
votes
6 answers

Getting RTF data out of Mac OS X pasteboard (clipboard)

According to the man page for pbpaste, -Prefer {txt | rtf | ps} tells pbpaste what type of data to look for in the pasteboard first. As stated above, pbpaste normally looks first for plain text data; however, …
Carl
  • 263
  • 3
  • 4
26
votes
3 answers

Open URL and Activate Google Chrome via Applescript

I have the following AppleScript that I wrote many years ago. I use this code to program buttons on my Harmony One universal remote to access online video services via Google Chrome. The code is not working. Google Chrome doesn't launch. I am…
ATLChris
  • 3,198
  • 7
  • 39
  • 65
26
votes
6 answers

How to send an imessage text with applescript, only in provided service?

Can somebody show me how to send a message directly to the user of iMessage via Messages app? tell application "Messages" if service type of service of buddy whose name is ("Name here" is "iMessage") then set x to 1 if service type of…
cre8eve
  • 371
  • 1
  • 6
  • 11
26
votes
3 answers

OSX: check if the screen is locked

Is there any way to check if screen is locked in shell or applescript? Not just check if screensaver is running, but screen is locked by energy saver settings or by pressing ⌃⇧⏏ (shift+control+eject). Thank you in advance.
LevB
  • 2,326
  • 3
  • 16
  • 14
25
votes
4 answers

Can AppleScript access browser tabs and execute javascript in them?

I'm curious if AppleScript can access each specific tab in a browser and execute some javascript in them. Anyone have ideas?
Allan
  • 2,586
  • 5
  • 26
  • 22
25
votes
5 answers

How do I write to a text file using AppleScript?

So, that's it. How can I write to a text file using AppleScript? I've tried googling around, but answers seem to be years old and I'm not really sure what should be the preferred idiom this days.
Juan A. Navarro
  • 10,595
  • 6
  • 48
  • 52
25
votes
1 answer

Manipulate OS X windows with script

Ok, so I'm trying to make my setup super simple by creating a script that I can run in the morning that will launch all the applications that I use in the day and lay them out across my 'spaces' how I like them. This was going ok and I was easily…
George Green
  • 4,807
  • 5
  • 31
  • 45
25
votes
7 answers

What is the quickest way to toggle hide/show hidden files on a Mac OS X Yosemite?

I'm on Yosemite, and I want to toggle hide/show all the hidden files on a Mac. Every-time, I want to do that I have to go to Terminal.app and run these command : To show defaults write com.apple.finder AppleShowAllFiles TRUE To hide defaults write…
iori
  • 3,236
  • 12
  • 43
  • 78
22
votes
4 answers

Import AppleScript methods in another AppleScript?

Is there a way to use defined AppleScript methods in other AppleScripts which reference the original AppleScript with something similar to import (f.e. in PHP)? I wrote a methode to set Skype status and mood-text: on setSkypeStatus(status,…
Jens Kohl
  • 5,899
  • 11
  • 48
  • 77
22
votes
3 answers

Print to Stdout with applescript

I'm trying to run an AppleScript script from the terminal, however I can't get it to print anything by calling osascript myFile.scpt "/path/to/a/file" I'm trying: on run fileName set unique_songs to paragraphs of (read POSIX file…
kb_
  • 1,245
  • 4
  • 18
  • 33