How to make typeAlias ?


Gerriet M. Denkmann
 

I have some (old) code like:

NSAppleEventDescriptor *eventDecriptor = ….
DescType descriptorType = eventDecriptor.descriptorType;

if ( descriptorType == typeAlias ) // ‘alis’
{
… How to get here?
}
else if ( descriptorType == typeFileURL ) // 'furl'
{
/* This can be triggered via AppleScript:

tell application “MyApp"
open POSIX file "/tmp/abc"
end tell
**/

}
else if ( descriptorType == typeBookmarkData ) // ‘bmrk'
{
// Select file(s) in Finder, drag onto MyApp Icon in Dock

}
else // error
{

}

How can I create a typeAlias eventDecriptor?
Or is typeAlias obsolete and will never happen?


Gerriet.


Shane Stanley
 

On 30 Aug 2017, at 7:15 pm, Gerriet M. Denkmann <g@mdenkmann.de> wrote:

… How to get here?
Your code answers that question. What you don't explain is what you want to do, presumably with the descriptor, when you get there.

You ask about creating a typeAlias eventDescriptor, but your code is triggered only if you already have such a thing.

--
Shane Stanley <sstanley@myriad-com.com.au>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


Gerriet M. Denkmann
 

On 30 Aug 2017, at 16:41, Shane Stanley <sstanley@myriad-com.com.au> wrote:

On 30 Aug 2017, at 7:15 pm, Gerriet M. Denkmann <g@mdenkmann.de> wrote:

… How to get here?
Your code answers that question. What you don’t explain is what you want to do, presumably with the descriptor, when you get there.
Sorry, if my explanation was not too clear.

This is the code:

- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
NSAppleEventManager *sharedAppleEventManager = [ NSAppleEventManager sharedAppleEventManager ];
[ sharedAppleEventManager setEventHandler: self
andSelector: @selector(handleAppleEvent:withReplyEvent:)
forEventClass: kCoreEventClass // 'aevt'
andEventID: kAEOpenDocuments // 'odoc'
];
}

- (void)handleAppleEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
{
NSAppleEventDescriptor *dirctObj = [ event descriptorForKeyword: keyDirectObject ];
DescType descriptorType = dirctObj.descriptorType;
if ( descriptorType == cAEList ) // 'list'
{
... some code here, calling pathFromDescriptor: for all items in list
}
else
{
NSString *path = [ self pathFromDescriptor: dirctObj ];
...
}
}

- (NSString *)pathFromDescriptor: (NSAppleEventDescriptor *)dirctObj;
{
DescType descriptorType = dirctObj.descriptorType;
if ( descriptorType == typeAlias ) // 'alis'
{
*** This is the stuff I need to test ***
… but I do not know how to trigger this path
… maybe some AppleScript?
}
else if ( descriptorType == typeFileURL ) // 'furl'
{
// get here via AppleScript
}
else if ( descriptorType == typeBookmarkData ) // 'bmrk'
{
// get here by dragging to dock
}
else // error
{
… error handling
}
}


Kind regards,

Gerriet.


Shane Stanley
 

On 30 Aug 2017, at 8:04 pm, Gerriet M. Denkmann <g@mdenkmann.de> wrote:

DescType descriptorType = dirctObj.descriptorType;
if ( descriptorType == typeAlias ) // 'alis'
{
*** This is the stuff I need to test ***
… but I do not know how to trigger this path
… maybe some AppleScript?
tell application “MyApp"
open alias "Macintosh HD:path:to:file" -- HFS path
end tell

or if you don't want to use an HFS path directly:

set theFile to POSIX file "/tmp/abc" as alias
tell application “MyApp"
open theFile
end tell

--
Shane Stanley <sstanley@myriad-com.com.au>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>