Questions tagged [nsapplescript]

37 questions
1
vote
0 answers

NSAppleScript memory leak

I have the code with OS X 10.6 SDK. There is one thing I can't understand. [1] int main(int argc, const char*argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *strScript = @"set theURL to \"\" \n" "tell…
tnrgus
  • 355
  • 1
  • 2
  • 14
1
vote
1 answer

When launching an application using applescript, I am not getting the splash screen

When launching an application using applescript, I am not getting the splash screen I am trying to launch an application and open a file using applescript. I am using this script in my c++ project. The application launcher code goes some what like…
sajas
  • 1,599
  • 1
  • 17
  • 39
1
vote
2 answers

NSApplescript escaping path with spaces in "do shell script.."

I'm having trouble escaping a path containing spaces using NSApplescript: // mybashscript is in the bundle app (NSlog grant that is ok!) NSDictionary*errorDict = nil; NSAppleScript*mycommand; NSString *mycommand = [mybashscript…
Mike97
  • 596
  • 5
  • 20
0
votes
1 answer

Make Menu Item Do Something AppleScript

I'm writing a program in AppleScript that creates a menu in the menu bar on MacOS. This is my code: use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "AppKit" property StatusItem : missing value property…
0
votes
0 answers

How to ask for administrative privilege only once in OSX?

So I have an app that runs shell command twice, once to disable sleep and then a few moments later to enable sleep. The code looks as follows: NSAppleScript(source: "do shell script \"sudo pmset -a disablesleep 1\" with administrator " + …
Singh
  • 41
  • 7
0
votes
2 answers

Privacy tab using AppleScript

I am trying to access the Privacy -> Accessibility tab using Applescript. Can anyone help me? I need to display a list of all the programs in the section: Accessibility Camera Microphone Photos etc... The request itself and the output in the…
0
votes
1 answer

Not authorised to send Apple Events to Finder from helper bundle

I'm having issues with executing AppleScript from the application helper bundle, which is contained in my main application bundle. I have a simple helper application bundle which only loads my script located in helpers' bundle Resources using…
mezo
  • 423
  • 1
  • 7
  • 19
0
votes
1 answer

Creating AppleScript for global keyboard shortcuts

I'm creating an AppleScript for my Mac that will tell Spotify to skip or go back a track based on keyboard shortcuts. I believe I have the code correct but cannot get the script to work properly and think it may be due to the if-then statements'…
0
votes
0 answers

How to close terminal window launched using Apple Script in Mac app

I have a Mac application. This app is executing following apple script using executeAndReturnError method of NSAppleScript class: set tempDir to path to temporary items as string set tempFilename to tempDir & "Test_Log.txt" set tempFilePath to…
0
votes
0 answers

NSAppleScript sandbox entitlement for Numbers

I'm needing to read from a Numbers spreadsheet in an App Store Sandboxed Mac app. I have it working fine until I enable the Sandbox. Apples docs say to use the com.apple.security.scripting-targets entitlement however I cannot find any entitlements…
0
votes
1 answer

NSAppleScript to highlight text in any Mac app with given NSRange

I am trying to highlight text in any Mac app through may custom Mac app, by making use of NSAppleScript. I have tried below code but it doesn't work. NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:[NSString…
Krishna Maru
  • 164
  • 13
0
votes
1 answer

Start/Assign macOS app with root privileges

I have written a macOS Cocoa app using XCode 9.2. The purpose of the app is as a wrapper to a set of shell commands so that users can run commands easily as required. The shell script allow the users to control a particular device driver for which…
TenG
  • 3,843
  • 2
  • 25
  • 42
0
votes
1 answer

Saving variables in applescript using plist's within application xcode

How do I make my script write to a Property List file without having to create a ".plist" file on the user's computer, but rather directly in the current application?
user7492670
0
votes
1 answer

Sending AppleEvent fails with sandbox

I try to show an element in the Calendar.app so the calendar is activated and the appropriate event is highlighted. I know how to do that but once Sandbox is on, I just get Calendar got an error: A privilege violation occurred. My code simply is…
qwerty_so
  • 35,448
  • 8
  • 62
  • 86
0
votes
0 answers

Objective C: Unable to run zip command from NSAppleScript

Here is the terminal command example that I want to run from NSAppleScript pushd "/Users/myUser/Library/Application Support" && zip -r "/Users/myUser/Desktop/myDataFolder.zip" "myDataFolder" && popd My Code: -(BOOL)runScriptAsAdmin:(NSString*)…
Vikas Bansal
  • 10,662
  • 14
  • 58
  • 100