Xojo Conferences
MBSOct2019CologneDE

how to send AE's to OSX apps with no creator code? (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: Re: ShowURL, OS X and #... and return
Next thread: [OFFTOPIC] FKeys & Keyboard Control Panel


how to send AE's to OSX apps with no creator code?   -   James Sentman
  Re: how to send AE's to OSX apps with no creator code?   -   Kevin Ballard
   Re: how to send AE's to OSX apps with no creator code?   -   James Sentman
    Re: how to send AE's to OSX apps with no creator code?   -   Patrick Wynne
   Re: how to send AE's to OSX apps with no creator code?   -   Seth Willits
  Re: how to send AE's to OSX apps with no creator code?   -   Ian Mantripp

how to send AE's to OSX apps with no creator code?
Date: 30.05.02 21:01 (Thu, 30 May 2002 16:01:45 -0400)
From: James Sentman
Ok, so I'm adding to the type/creator discussion, but it's not my
opinion on what they should do, it's a specific implementation
question relevant to RB.

In RB currently, you target an apple event by creator code of the
target application. That's fine until OSX where now some applications
are not getting a creator code assigned to them anymore.

So how do I target that app? The only alternative method of targeting
that I've explored outside of RB is by process serial number, but
that doesn't work if the program isn't already running, and you can
only access that in RB with a dozen or so declares.

So if creator codes are indeed being "depreciated" how will we target
our AE's? Are there already apps out there that are scriptable but
not from RB? Might there be some double secret API out there
somewhere for targeting via the bundle identifier (which would make
an OK replacement for creator codes AFAIAC since it's not limited to
4 characters)

Just want RS to start thinking about that!

-James

---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>

Re: how to send AE's to OSX apps with no creator code?
Date: 30.05.02 21:12 (Thu, 30 May 2002 16:12:03 -0400)
From: Kevin Ballard
On 5/30/02 4:01 PM, "James Sentman" <<email address removed>> wrote:

> So how do I target that app? The only alternative method of targeting
> that I've explored outside of RB is by process serial number, but
> that doesn't work if the program isn't already running, and you can
> only access that in RB with a dozen or so declares.

Only one declare is necessary, really, although it depends on which app
you're trying to get. Check out CarbonDeclareLibrary if you need to get
PSN's.

Re: how to send AE's to OSX apps with no creator code?
Date: 30.05.02 21:28 (Thu, 30 May 2002 16:28:01 -0400)
From: James Sentman
>On 5/30/02 4:01 PM, "James Sentman" <<email address removed>> wrote:
>
>> So how do I target that app? The only alternative method of targeting
>> that I've explored outside of RB is by process serial number, but
>> that doesn't work if the program isn't already running, and you can
>> only access that in RB with a dozen or so declares.
>
>Only one declare is necessary, really, although it depends on which app
>you're trying to get. Check out CarbonDeclareLibrary if you need to get
>PSN's.

Only one declare to get the PSN perhaps, but then you have to do a
not insignificant amount of work to put that into the AppleEvent;)

Once you've got the PSN you'll need to put that info into a memory block:

ThePSN = newMemoryBlock( 8)

ThePSN.long( 0) = MyProcessRec.SerialHigh
ThePSN.long( 4) = MyProcessRec.SerialLow

Then you need to create an AEDesc to hold the info in the proper
format for putting into the event like:

dim err as Integer
dim aedesc as MemoryBlock

#if targetCarbon then
Declare Function AECreateDesc Lib "CarbonLib" (typeCode as OSType,
dataPtr as CString, dataSize as Integer, result as Ptr) as Integer
#else
Declare Function AECreateDesc Lib "InterfaceLib" (typeCode as
OSType, dataPtr as CString, dataSize as Integer, result as Ptr) as
Integer Inline68K("303C0825A816")
#endif

aedesc = NewMemoryBlock(8)

err = AECreateDesc("psn ", ThePSN, ThePSN.size, aedesc)

now you've got an apple event parameter that you can insert into the
event that you've already created via regular RB means something like:

#if targetCarbon then
Declare Function AEPutAttributeDesc Lib "CarbonLib" (theAppleEvent
as integer, theAEKeyword as OSType, theAEDesc as Ptr) as Integer
#endif
dim i as integer
dim aeptr as integer

aeptr = TheRBAppleEvent.ptr
i = AEPutAttributeDesc( aeptr, "addr", aedesc)

And then you have overwritten the original target that you created
and are now targeted to the process by serial number. However if the
process is not running it will fail. The app wont be launched as it
would with a creator code.

There are other ways to target an AE like this too, I suspect that we
could overcome the errors in RB's remote targeting by doing this work
ourselves, but I haven't had a chance to play with this yet.

The only place that this code would come in handy as far as I can
tell is when you may have several programs running with the same
creator code and you need to send events to specific ones. Which is
exactly how I'm using it.

BUT, that doesn't solve the original problem, how do I target an
event to a program in OSX that doesn't have a creator code.

Enjoy,
James

Re: how to send AE's to OSX apps with no creator code?
Date: 30.05.02 22:06 (Thu, 30 May 2002 14:06:28 -0700 (PDT))
From: Patrick Wynne
Hmm, could you try something like:

1. build the AE you wish to send
2. using Process Mgr declares,is the app running?
a. yes, target your AE by PSN
b. no, stuff your AE into a LaunchParamBlockRec and use
LaunchApplication to launch the app and send the AE to it

I've managed to use LaunchApplication to send an AE to a non-running
app and I think it's supported on OS X, but I can't confirm. All you
would then need is the FSSpec to the app. Plus, LaunchApplication will
return to you the PSN of the now-running app, which you can use in the
future to target more AEs to it. Everyone's a winner!

Worth a try, anyway! :)

Patrick

--- James Sentman <<email address removed>> wrote:
> >On 5/30/02 4:01 PM, "James Sentman" <<email address removed>> wrote:
> >
> >> So how do I target that app? The only alternative method of
> targeting
> >> that I've explored outside of RB is by process serial number, but
> >> that doesn't work if the program isn't already running, and you
> can
> >> only access that in RB with a dozen or so declares.
> >
> >Only one declare is necessary, really, although it depends on which
> app
> >you're trying to get. Check out CarbonDeclareLibrary if you need to
> get
> >PSN's.
>
> Only one declare to get the PSN perhaps, but then you have to do a
> not insignificant amount of work to put that into the AppleEvent;)
>

*** bunches o' code snipped ***

=gD<Patrick Wynne
<http://home.earthlink.net/~patwynne/>

=_D_
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>

Re: how to send AE's to OSX apps with no creator code?
Date: 31.05.02 08:59 (Fri, 31 May 2002 00:59:37 -0700)
From: Seth Willits
On 5/30/02 1:12 PM, the NSA intercepted the following message from "Kevin
Ballard" <kevin@sb.org>:

>> So how do I target that app? The only alternative method of targeting
>> that I've explored outside of RB is by process serial number, but
>> that doesn't work if the program isn't already running, and you can
>> only access that in RB with a dozen or so declares.
>
> Only one declare is necessary, really, although it depends on which app
> you're trying to get. Check out CarbonDeclareLibrary if you need to get
> PSN's.

Does it work off the name in the plst?

Seth Willits
---------------------------------------------------------------------------
President and Head Developer of Freak Software - http://www.freaksw.com
Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com

"More praise of peace is easy but ineffective. What is needed is active
participation in the fight against war and everything that leads to it."
-- Albert Einstein
---------------------------------------------------------------------------


---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>

Re: how to send AE's to OSX apps with no creator code?
Date: 31.05.02 10:19 (Fri, 31 May 2002 11:19:06 +0200)
From: Ian Mantripp
on 30/05/02 10:01 pm, James Sentman wrote:

> So how do I target that app? The only alternative method of targeting
> that I've explored outside of RB is by process serial number, but
> that doesn't work if the program isn't already running, and you can
> only access that in RB with a dozen or so declares.
>
> So if creator codes are indeed being "depreciated" how will we target
> our AE's? Are there already apps out there that are scriptable but
> not from RB? Might there be some double secret API out there
> somewhere for targeting via the bundle identifier (which would make
> an OK replacement for creator codes AFAIAC since it's not limited to
> 4 characters)

Well I recently wrote apple events that target a Cocoa app that doesn't, as
such, have a creator code. However it did have an "AppleEventCode" which I
found by opening the bundle and in the resources directory there was a file
called xxxxxx.scriptSuite. I don't know if all scriptable Cocoa apps have
this but it is a cool document to have if you are writting apple events to
control it.

Ian
-------------------------------------------------------------------------
Ian Mantripp - codeboy Telemak
Tel: +32 (0)2 475 3333 Streaming Media Technologies
Mobile: +32 (0)476 66 3545 <http://www.telemak.com>
-------------------------------------------------------------------------


---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>