• 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
Re: Running AppleScript without Window Server context
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running AppleScript without Window Server context


  • Subject: Re: Running AppleScript without Window Server context
  • From: Dirk Stegemann <email@hidden>
  • Date: Fri, 6 May 2005 20:59:05 +0200

Hi,

Am 06.05.2005 um 11:10 schrieb Nathan Day:

If you use the Carbon API you can set a scripting components execution mode to never interact with the user (kOSAModeNeverInteract).

Thanks a lot for pointing this out, it sounds exactly like what I was looking for..



On my web site I have my own wrapper of apples carbon AppleScript API which gives you more control than NSAppleScript, include setting of execution mode flags.

Thanks again for sharing your source code! Although I had a look at it, I seem to need only these two API calls:

   OpenDefaultComponent()
   OSADoScript()

When my user is logged in, I see the script working, although OSADoScript() returns -50 (badParam); because the error doesn't seem to be crucial, I'd stick with this, but maybe someone sees the bug I build into the code (I'll post the code below).

Unfortunately, I still get the "kCGErrorRangeCheck : Window Server communications from outside of session allowed for root and console user only" error when I switch away from the user whose cron executes this tool.
Are you sure it is sufficient to specify the 'kOSAModeNeverInteract' modeFlags parameter...?
Any other ideas?


Thanks in advance!


-----snip----- { OSType componentType = kOSAComponentType; OSType componentSubType = kAppleScriptSubtype;

    OSAError myErr = noErr;

    ComponentInstance	scriptingComponent = 0;
    const AEDesc* sourceData = 0;
    OSAID contextID = kOSANullScript;
    DescType desiredType = typeChar;
    long modeFlags = kOSAModeNeverInteract;
    AEDesc* resultingText = 0;

// sourceAEDesc is a valid NSAppleEventDescriptor* obtained through [NSAppleEventDescriptor descriptorWithString:]
sourceData = [sourceAEDesc aeDesc];


printf("OpenDefaultComponent...");
scriptingComponent = OpenDefaultComponent(componentType, componentSubType);
printf("...ok \n");


if (scriptingComponent != 0) {
printf("OSADoScript...");
myErr = OSADoScript(scriptingComponent, sourceData, contextID, desiredType, modeFlags, resultingText);
printf("...myErr = %d \n", myErr);
}
}
-----snip-----


The last log output from the tool is "OpenDefaultComponent...".


Regards, Dirk Stegemann _______________________________________________ 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
References: 
 >Running AppleScript without Window Server context (From: Dirk Stegemann <email@hidden>)
 >Re: Running AppleScript without Window Server context (From: Mike Paquette <email@hidden>)
 >Re: Running AppleScript without Window Server context (From: Nathan Day <email@hidden>)

  • Prev by Date: Re: Function to write to one pixel
  • Next by Date: Re: Function to write to one pixel
  • Previous by thread: Re: Running AppleScript without Window Server context
  • Next by thread: Releasing an NSWindow without destroying the underlying Carbon windowRef?
  • Index(es):
    • Date
    • Thread