• 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
Calling AppleScript from a Cocoa app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Calling AppleScript from a Cocoa app


  • Subject: Calling AppleScript from a Cocoa app
  • From: Phil <email@hidden>
  • Date: Tue, 6 Sep 2005 03:29:07 -0400

Does anyone have suggestions / pointers re: calling AppleScript from Cocoa apps? This is an area that Apple docs don't seem to cover in a way that I am finding helpful.

Specifically, I need to call AppleScript code (both with and without parameters) from a Cocoa app preferably by calling functions stored in a central script. In playing around with some code found on the web, it appears to be the core of what is needed: no problem getting a sample function to display a dialog with a passed parameter. However, when the same code is called to pass a parameter to a different function in the same script, it fails with a -1708 error which seems to mean 'the AppleEvent was not handled by any handler'... which I find clear as mud since the function executes correctly via Script Editor.

Below is the AEDebug* output on the failing script:

AE2000 (3184): Sending an event:
------oo start of event oo------
{ 1 } 'aevt':  ascr/gdut (ppc ){
          return id: 208666624 (0xc700000)
     transaction id: 0 (0x0)
  interaction level: 64 (0x40)
     reply required: 1 (0x1)
             remote: 0 (0x0)
  target:
    { 2 } 'psn ':  8 bytes {
      { 0x0, 0x2 } (nibtext)
    }
  optional attributes:
    < empty record >
  event data:
    { 1 } 'aevt':  - 0 items {
    }
}

------oo  end of event  oo------
AE2000 (3184): Reply of SendToSelf (err == -1708):
------oo start of event oo------
{ 1 } 'aevt':  aevt/ansr (ppc ){
          return id: 208666624 (0xc700000)
     transaction id: 0 (0x0)
  interaction level: 112 (0x70)
     reply required: 0 (0x0)
             remote: 0 (0x0)
  target:
    { 3 } 'psn ':  8 bytes {
      { 0x0, 0x2 } (nibtext)
    }
  optional attributes:
    < empty record >
  event data:
    { 1 } 'aevt':  - 1 items {
      key '----' -
        { 1 } 'list':  - 0 elements {
        }
    }
}

------oo  end of event  oo------
AE2000 (3184): Sending an event:
------oo start of event oo------
{ 1 } 'aevt':  ascr/gdut (ppc ){
          return id: 208666626 (0xc700002)
     transaction id: 0 (0x0)
  interaction level: 64 (0x40)
     reply required: 1 (0x1)
             remote: 0 (0x0)
  target:
    { 2 } 'psn ':  8 bytes {
      { 0x0, 0x2 } (nibtext)
    }
  optional attributes:
    < empty record >
  event data:
    { 1 } 'aevt':  - 1 items {
      key '----' -
        { 1 } 'long':  4 bytes {
          -2 (0xfffffffe)
        }
    }
}

------oo  end of event  oo------
AE2000 (3184): Reply of SendToSelf (err == -1708):
------oo start of event oo------
{ 1 } 'aevt':  aevt/ansr (ppc ){
          return id: 208666626 (0xc700002)
     transaction id: 0 (0x0)
  interaction level: 112 (0x70)
     reply required: 0 (0x0)
             remote: 0 (0x0)
  target:
    { 3 } 'psn ':  8 bytes {
      { 0x0, 0x2 } (nibtext)
    }
  optional attributes:
    < empty record >
  event data:
    { 1 } 'aevt':  - 0 items {
    }
}

------oo  end of event  oo------

Thanks,
Phil

_______________________________________________
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


  • Follow-Ups:
    • Re: Calling AppleScript from a Cocoa app
      • From: "email@hidden" <email@hidden>
  • Prev by Date: Re: NSTableView
  • Next by Date: [ANN] HOM paper available
  • Previous by thread: Re: CGS differences from Panther to Tiger
  • Next by thread: Re: Calling AppleScript from a Cocoa app
  • Index(es):
    • Date
    • Thread