0

I have an very simple AppleScript:

tell application "Opera"
   get URL of active tab of window 1
end tell

This is the translation to AppleEvents:

osascript browser.scpt 
{core,getd target='psn '[Opera] {----={form=prop,want=prop,seld=URL ,from={form=prop,want=prop,seld=acTa,from={form=indx,want=cwin,seld=1,from=NULL-impl}}}} attr:{csig=65536 returnID=15130}

For some reasons I cannot use AppleScript so I need to translate those events into C code.

So far I have this after looking at some examples and reading some doc:

AppleEvent theEvent;
AEIdleUPP theIdleProc = NewAEIdleUPP((AEIdleProcPtr)&TheIdleFunction );
if( NULL != theIdleProc )
{
    char* arg = "Opera";
    AEAddressDesc addDesc;
    err = AECreateDesc( typeProcessSerialNumber, &arg, sizeof( arg ), &addDesc );
    printf("AECreateDesc error --> %d\n", err);
    if( noErr == err )
    {
        // my event creation
        // create event:
        err = AECreateAppleEvent( 'core', 'getd', &addDesc, kAutoGenerateReturnID, kAnyTransactionID, &theEvent );
        // create descriptors needed
        AEDesc indexDescriptor;
        long indexVerb = 'indx';
        err = AECreateDesc('enum',&indexVerb,4,&indexDescriptor);
        AEDesc nullDsc;
        err = AECreateDesc(typeNull, nil, 0, &nullDsc);
        //seld = 1
        long seldIndex = 1;
        AEDesc seldIndexDesc;
        err = AECreateDesc(typeSInt64 ,&seldIndex,4,&seldIndexDesc);
        err = CreateObjSpecifier('cwin',&nullDsc,'ID  ',&theSeldDesc,true,&theThirdObjSpec);
    }
}
    return 0;

But I am kind of stuck here. How do I connect "form=indx" for example to "want=cwin" Do I need to create AEDesc for form part, then for want part and also for seld?

Also what is the meaning of last line in raw event? "attr:{csig=65536 returnID=15130}"

I am kind of lost with this. I would appreciate small example to use as guide

Thanks in advance

RuLoViC
  • 825
  • 7
  • 23
  • 1
    Is there a specific reason you need to use the old C API? You're really making a rod for your own back here. If for some reason it's unavoidable, search the web for "Inside Macintosh" + "IAC" as that's about the best and newest documentation you're going to find for it. – foo Dec 06 '18 at 20:00
  • Yep, I need to use this way because using AppleEvents with Mojave release causes that my application is displaying popups asking for permissions continuously. – RuLoViC Dec 06 '18 at 20:04
  • 1
    Why do you imagine that the old APIs would not also be subject to the new security/privacy controls? That would be a security hole and I doubt it will work any better. Even if it does now, Apple is likely to plug such a hole in the future. – Ken Thomases Dec 06 '18 at 20:33
  • What Ken says. Security is OS level. [Go research](https://www.google.com/search?q=mojave+apple+events) how Mohave remembers the user's AE permissions for an app, and then figure out why it doesn't remember them for yours. – foo Dec 07 '18 at 18:58

0 Answers0