applescript-objc

Swift and scriptingbridge object initialization

六眼飞鱼酱① 提交于 2019-12-03 07:52:42
问题 I'm trying to write an application for swift control iTunes. But when initializing the application returns an object of type AnyObject , but must iTunesApplication. This object does not respond to methods and variables iTunes. Who knows how to make it work? var iTunes = SBApplication.applicationWithBundleIdentifier("com.apple.iTunes") The iTunes.h header also holds classes that I need to access but cannot. These classes cause a compilation error as if they are not in a declared a iTunes.h.

Can AppleScript access browser tabs and execute javascript in them?

限于喜欢 提交于 2019-12-03 05:57:07
问题 I'm curious if AppleScript can access each specific tab in a browser and execute some javascript in them. Anyone have ideas? 回答1: For Google Chrome , use execute from AppleScript Chromium Suite: execute  v : Execute a piece of javascript. execute specifier : The tab to execute the command in. javascript text : The javascript code to execute. Example: tell application "Google Chrome" execute front window's active tab javascript "alert('example');" end tell Can be done in Safari either: tell

Swift and scriptingbridge object initialization

孤者浪人 提交于 2019-12-02 21:20:13
I'm trying to write an application for swift control iTunes. But when initializing the application returns an object of type AnyObject , but must iTunesApplication. This object does not respond to methods and variables iTunes. Who knows how to make it work? var iTunes = SBApplication.applicationWithBundleIdentifier("com.apple.iTunes") The iTunes.h header also holds classes that I need to access but cannot. These classes cause a compilation error as if they are not in a declared a iTunes.h. Why is this happening to me is not yet clear. The whole list of classes that are declared a iTunes.h in

How to use NSAutoreleasePool in AppleScriptObjC

删除回忆录丶 提交于 2019-12-02 03:37:30
I am wondering how to stop another function from a background function. In addition, I have to drain NSAutoreleasePool, but I don't know how to do it. I think this app sometimes freeze if I don't release pool. property i : 0 property myLabel : missing value on myStartButtonHandler_(sender) my performSelectorInBackground_withObject_("start", missing value) -- This code prevents "Stop" Button from freezing. end myStartButtonHandler_ on myStopButtonHandler_(sender) -- I want to stop start() function and drain AutoreleasePool! -- I don't want to use "quit me" because I want to stop only start()

Pass Variable or String from OS X Cocoa App to Applescript

送分小仙女□ 提交于 2019-12-01 09:08:51
问题 I would like to pass a variable to applescript. For example, I type some words in textfield of a Cocoa-App (not cocoa-applescript app).Then, it will be a variable in Applescript for future use. I use Applescript to tell some software to run some files. I've tried How Can I Pass a String From Applescript to Objective C the method here. It could add the first lines in applescript using initialwithSource . I have to write a long sentence. Also if I've already have the applescript, I have to

Apple Script working fine but with Objective C Library not getting expected out put

吃可爱长大的小学妹 提交于 2019-11-28 02:23:38
I tried running apple script #! /usr/bin/osascript do shell script "chmod 777 /Library/ColorSync/Profiles" with administrator privileges It perfectly working in script editor and terminal. But not able to run with Objective C. Any help will be appreciated. -(void)executeAppleScript{ NSDictionary* errorDict; NSAppleEventDescriptor* returnDescriptor = NULL; NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource: @"#! /usr/bin/osascript do shell script \"chmod 777 /Library/ColorSync/Profiles\" with administrator privileges"]; returnDescriptor = [scriptObject executeAndReturnError: