• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Applescripts and plug-ins.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Applescripts and plug-ins.


  • Subject: Applescripts and plug-ins.
  • From: Jeremy Sacket <email@hidden>
  • Date: Thu, 18 Nov 2004 17:41:53 -0600

I am trying to write a plug-in for an existing application. I am having trouble making my plugin Applescriptable.
I have searched high and low for examples or what not. I have successfully wrote a sample app that is scriptable, but can not
get it to work with a bundle. The script can not access my objects. I even modified an existing application to load as a plug-in. It is below.


Thanks for any help.


////////Applescript for testing the plugin in MyApp. tell application "MyApp" activate set title1 to the title of the testobject display dialog title1 set the title of the testobject to "test2" set title2 to the title of the testobject display dialog "Test2" end tell


//////////The Main class of the plug-in. @implementation AppDelegate + (void)initialize{ NSLog(@"AppDelegate"); theObject = [[SimpleObject alloc] init]; [theObject setTitle: @"Test Object"]; NSLog([[NSApp theObject] title]);

}

- (SimpleObject *) theObject {
    return theObject;
}

- (void) setTheObject: (SimpleObject *) newTheObject {
    [newTheObject retain];
    [theObject release];
    theObject = newTheObject;
}


////The object @implementation SimpleObject

- (NSString *) title {
    return title;
}

- (void) setTitle: (NSString *) newTitle {
    [newTitle retain];
    [title release];
    title = newTitle;
}

- (void) dealloc {
    [title release];
}

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd";>


<!-- The purpose of the script suite is to describe the parts of your application's
object model that you want to be accessible via AppleScript. -->


<plist version="1.0">
<dict>
<!-- This is the name of your application -->
<key>Name</key>
<string>ASTest</string>
<!-- This is the AppleEvent code you want associated with your application -->
<key>AppleEventCode</key>
<string>AStS</string>
<key>Classes</key>
<dict>
<!-- This is here to add ASTest's extra functionality to the standard NSApp class. -->
<key>NSApplication</key>
<dict>
<key>AppleEventCode</key>
<!-- We are using the standard AppleEvent code associated with the NSApplication class -->
<string>capp</string>
<key>Attributes</key>
<dict>
<!-- This key must match the name of an instance variable accessible through key-value (getter/setter) methods in the class -->
<key>theObject</key>
<dict>
<!-- The AppleEvent code we are assigning to this attribute. -->
<!-- Note that this should *not* be the same as the code used for the field type itself (see below). -->
<key>AppleEventCode</key>
<string>TOBj</string>
<key>ReadOnly</key>
<string>NO</string>
<!-- The type references the SimpleObject class defined below -->
<key>Type</key>
<string>SimpleObject</string>
</dict>
</dict>
<!-- NSApplication is one of AppleScript's predefined types -->
<key>Superclass</key>
<string>NSCoreSuite.NSApplication</string>
</dict>
<key>SimpleObject</key>
<dict>
<key>AppleEventCode</key>
<string>SMPo</string>
<key>Attributes</key>
<dict>
<!-- As above, this key must match the name of an instance variable accessible through key-value methods -->
<key>title</key>
<dict>
<key>AppleEventCode</key>
<string>SOTi</string>
<key>ReadOnly</key>
<string>NO</string>
<key>Type</key>
<string>NSString</string>
</dict>
</dict>
<!-- SimpleObject is our own custom type, not one of the predefined set. -->
<key>Superclass</key>
<string>NSCoreSuite.AbstractObject</string>
</dict>
</dict>
</dict>
</plist>



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd";>


<!-- The purpose of the script terminology is to define how the object model (classes,
attributes, commands, etc.) described in your script suite maps to an actual AppleScript
"vocabulary." -->


<plist version="1.0">
<dict>
<!-- This text appears as the name of your application's suite in the scripting dictionary -->
<key>Name</key>
<string>AS Test Suite</string>
<!-- This text appears as a description in the header of your application's suite in the scripting dictionary -->
<key>Description</key>
<string>AS Test's AppleScript interface</string>

<key>Classes</key>
<dict>
<!-- This key relates back to the NSApp class definition in ASTest.scriptSuite -->
<key>NSApplication</key>
<dict>
<!-- These are the the names the NSApp class goes by in AppleScript -->
<key>Name</key>
<string>application</string>
<key>PluralName</key>
<string>applications</string>
<!-- This is the description of the application class that appears in the scripting dictionary -->
<key>Description</key>
<string>AS Test's top level scripting object.</string>
<key>Attributes</key>
<dict>
<!-- This key relates back to the NSApp "theObject" attribute definition in ASTest.scriptSuite -->
<key>theObject</key>
<dict>
<!-- This is the name used to access the "theObject" attribute in AppleScript -->
<key>Name</key>
<string>testobject</string>
<!-- This is the description of the testobject attribute that appears in the scripting dictionary -->
<key>Description</key>
<string>A very simple object with a title that can be read or changed.</string>
</dict>
</dict>
</dict>
<!-- This key relates back to the SimpleObject class definition in ASTest.scriptSuite -->
<key>SimpleObject</key>
<dict>
<!-- These are the the names the SimpleObject class goes by in AppleScript -->
<key>Name</key>
<string>simpleobject</string>
<key>PluralName</key>
<string>simpleobjects</string>
<!-- This is the description of the simpleobject class that appears in the scripting dictionary -->
<key>Description</key>
<string>A simple object.</string>
<key>Attributes</key>
<dict>
<!-- This key relates back to the SimpleObject "title" attribute definition in ASTest.scriptSuite -->
<key>title</key>
<dict>
<!-- This is the name used to access the "title" attribute in AppleScript -->
<key>Name</key>
<string>title</string>
<!-- This is the description of the title attribute that appears in the scripting dictionary -->
<key>Description</key>
<string>The title of the object.</string>
</dict>
</dict>
</dict>
</dict>
</dict>
</plist>


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: RE: Drag and Drop
  • Next by Date: (no subject)
  • Previous by thread: Re: Compiles everything
  • Next by thread: (no subject)
  • Index(es):
    • Date
    • Thread