Programmatically “dropping” a document on an application

I have a third-party application that works by dropping a document onto the application icon. I would like to be able to do this drop from my app. I tried using a shell and executing

open appshellpath docshellpath

to no avail. Any suggestions?

does your application accept command line parameters? the command line parameter would be the docshellpath.

In the open event of the application, you place the document path in the appropriate place: property or other. Then in the show event (when everything is ready in the application) if there is something specified in the above mentioned property, you open the document.

I don’t have access to the target application’s code, but I suspect the answer is No.

ah. I thought that you were dropping a document on your application. Of course, you don’t control the third party application. My suggestion makes no sense at all then…

If you’re dropping onto the application icon specifically (and not a drop zone in the app) you should be able to just open a document with the app to use the same functionality. If the document type is set to open with that app already, FolderItem.Launch should work, if not I posted a declare somewhere around here for opening a document with a specific app.

If you can’t find it, I can pull it out of Answers later when I have some time.

[quote=406059:@Tim Parnell]If you’re dropping onto the application icon specifically (and not a drop zone in the app) you should be able to just open a document with the app to use the same functionality. If the document type is set to open with that app already, FolderItem.Launch should work, if not I posted a declare somewhere around here for opening a document with a specific app.

If you can’t find it, I can pull it out of Answers later when I have some time.[/quote]

That declare would be great, if you can find it.

If you use MBS Plugin, we suggest checking the launch service functions:

https://www.monkeybreadsoftware.net/launchservices-mbslaunchservicesplugin-method.shtml#13

Here’s the declare way too

  // Launch help with selected preview browser
  declare function NSClassFromString Lib "Foundation" (name as CFStringRef) as Ptr
  declare function sharedApplication Lib "AppKit" Selector "sharedWorkspace" (obj As Ptr) as Ptr
  dim sharedWorkspace as ptr = sharedApplication(NSClassFromString("NSWorkspace"))
  
  declare function openFile Lib "AppKit" Selector "openFile:withApplication:" (id as ptr, urlString as CFStringRef, appName as CFStringRef) as Boolean
  call openFile(sharedWorkspace, fTheDocument.NativePath, "AppName.app")

[quote=406070:@Tim Parnell]Here’s the declare way too
[/quote]

Thanks Tim. Works like a charm.