Questions tagged [nsapplescript]
37 questions
7
votes
3 answers
My applescript doesn't work any more when I upgrade my OS X to 10.9
The following code is trying to open the proxies settings dialog,
NSAppleScript *a = [[NSAppleScript alloc] initWithSource:@"tell application \"System Preferences\"\nset current pane to pane \"com.apple.preference.network\"\nactivate\nend…

Grey
- 253
- 4
- 15
3
votes
1 answer
Apple Script fails when run from within a macOS Swift-based application
SOLUTION:
I needed to do two things to solve my problem:
1) Add the following to my app's entitlements file:
com.apple.security.temporary-exception.apple-events
com.apple.Mail
2) Add the following to…

RobertJoseph
- 7,968
- 12
- 68
- 113
3
votes
4 answers
How to pass date information to AppleScript?
I am making one app that can run AppleScript via NSAppleScript.
Everything had been fine but I haven't been able to figure out how to pass date information from my app to AppleScript. (Since AppleScript has date type, I suppose this is possible)
The…

Terry
- 337
- 2
- 9
3
votes
1 answer
Is there an App store entitlement for NSAppleScript(source: "do shell script \"sudo" commands?
For example, my app uses the following command with the OS handling a pop up alert to request the admin password to authenticate as root. Is there an entitlement that will allow me run this from within the sandbox ?
@IBAction func…

tsh79
- 69
- 4
2
votes
2 answers
Convert list of AppleScript strings to a Swift array
I have a complicated AppleScript that returns a list of strings that I need to access from Swift. I've boiled it down to a simple example and I just can't figure out how to map the AppleScript strings to an array of Swift strings.
let…

RobertJoseph
- 7,968
- 12
- 68
- 113
2
votes
2 answers
Using NSAppleScript with Sierra - send action not happening
I am using NSAppleScript for sending email from my OSX application.
It was working fine before but now when I use new XCode 9.0 with Sierra 10.12.6 I have one problem. Application will create email and open Mail window containing email and message…

rrodic
- 21
- 2
2
votes
1 answer
“is not allowed for assistive access” error when running AppleScript in Mac app
My code is
NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
@"\
tell application \"System Preferences\"\n\
set current pane to pane id…

Jingxizi
- 51
- 4
2
votes
1 answer
Sandbox entitlement to script iTunes via NSAppleScript
I'm trying to script iTunes from NSAppleScript in my Cocoa app in order to add a file to the library.
In my entitlements file, I added the following:
com.apple.security.scripting-targets
com.apple.itunes
…

beeb
- 1,187
- 11
- 32
2
votes
0 answers
Cocoa - Toggling Mirror Display in Display Preferences by embedded apple script?
After setting accessibility ON, I am trying to Mirror Displays using the following objective-c code with apple script:
- (void) toggleMirrorDisplayOption
{
NSString *script = @"\
tell application \"System Preferences\"\n\
set current…

Piyush Mathur
- 1,617
- 16
- 33
2
votes
1 answer
How can an app send a (basic) Apple Event to itself in Cocoa?
I thought I was so slick in rewriting my handler for the "Open" menu command in the application delegate:
- (IBAction)openDocument:(id)sender {
NSOpenPanel * const panel = [NSOpenPanel openPanel];
panel.allowsMultipleSelection = YES;
…

CTMacUser
- 1,996
- 1
- 16
- 27
2
votes
1 answer
-[NSAppleScript executeAndReturnError:] gives error with script that works in AppleScript Editor
I'm trying to find out if QuickTime player is paused or playing from Cocoa. I use the following small AppleScript in Script Debugger and AppleScript Editor and it returns true or false as expected:
tell application "QuickTime Player" to tell…

Chuck
- 4,662
- 2
- 33
- 55
1
vote
0 answers
Slack > Applescript/JS on new DM?
I'm trying to do some automation on new slack DM, (I'm using Applescript with some JS code),
I can read the numbers of unread message with this AppleScript
tell application "Safari"
set unreadmessage to do JavaScript…

Kevin
- 1,076
- 4
- 22
- 49
1
vote
0 answers
Getting errors when executing AppleScript from within Swift App
I'm using the NSAppleScript to run some code from within a swift app. The code runs and launches the Photos app but then I get the following error and no photos are exported:
error: {
NSAppleScriptErrorAppName = Photos;
…

user1542125
- 593
- 6
- 16
1
vote
0 answers
Asynchronously execute two applescript in cocoa application
I am converting all iwork documents file OSX type to Microsoft file type like .pages to .doc .keynotes to .pdf and .numbers to .xls. I have written 3 different script for each type and calling an event with arguments from cocoa application…

vjk
- 11
- 2
1
vote
2 answers
Unexpectedly found nil while unwrapping an Optional value (AppleScript result)
I am trying to make a program in Swift 2 that runs and gets the result of an AppleScript script.
Here is my code:
import Foundation
func runAppleScript(script:String) -> String
{
let errorInfo =…

iProgram
- 6,057
- 9
- 39
- 80