• 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: Custom send proc (migrated from cocoa-dev list)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom send proc (migrated from cocoa-dev list)


  • Subject: Re: Custom send proc (migrated from cocoa-dev list)
  • From: "email@hidden" <email@hidden>
  • Date: Thu, 21 Jan 2010 09:55:28 +0000

On 20 Jan 2010, at 23:47, has wrote:
>  The send proc callback (which should be installed prior to invoking the script and have the same signature as AESend) is called by the AS component whenever it needs to dispatch an Apple event. You can then do whatever naughtiness you like (including passing the call onto AESend proper).
>
The send proc signature is an augmented version of the AESend signature.

The original issue here was to detect errAENoUserInteraction and conditionaly transform a foundation tool into a foreground GUI.
The custom send proc approach works well.
Thanks for all your input.

These scripts are often executed as remote instances (as an alternative to remote targeting using eppc).
It would seem possible, rather than optionally enabling/disabling remote user interaction, to route the interacting event back over the network to the originating machine.
AEFlattenDesc() and AEUnflattenDesc() provide AE serialisation services.

Does this sound practicable - or do monsters wait in the weeds?

/*
 * function MGSCustomSendProc
 */
OSErr MGSCustomSendProc( const AppleEvent *anAppleEvent, AppleEvent *aReply, AESendMode aSendMode, AESendPriority aSendPriority, long aTimeOutInTicks, AEIdleUPP anIdleProc, AEFilterUPP aFilterProc, long refCon )
{
	#pragma unused(refCon)

	OSErr result = noErr;

	// send the event as normal
	result = AESend(anAppleEvent, aReply, aSendMode, aSendPriority, aTimeOutInTicks, anIdleProc, aFilterProc);

	//
	// look for no user interaction required.
	// if the user interaction was disallowed then transform the process
	// into a foreground application
	//
	if (result == errAENoUserInteraction && ![MGSAppleScriptRunner isForegroundApplication]) {

		// transform to foreground application to allow for user interaction
		if ([MGSAppleScriptRunner transformToForegroundApplication]) {

			// resend the event
			result = AESend(anAppleEvent, aReply, aSendMode, aSendPriority, aTimeOutInTicks, anIdleProc, aFilterProc);
		}
	}

	return result;
}

Thanks

Jonathan

>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Core Data SQLite share hang on 10.6.2
  • Next by Date: Ignore last two posts - misdirected
  • Previous by thread: Core Data SQLite share hang on 10.6.2
  • Next by thread: Ignore last two posts - misdirected
  • Index(es):
    • Date
    • Thread