• 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: openPanel using Automator Runner
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: openPanel using Automator Runner


  • Subject: Re: openPanel using Automator Runner
  • From: Jim Skibbie <email@hidden>
  • Date: Wed, 19 Jun 2013 16:32:55 +0000
  • Thread-topic: openPanel using Automator Runner

Shane-

Thanks for the info about Automator Runner. I've killed the idea of using Automator Runner since it is not supported past OS X 10.6. Also, neither passing a file URL nor a POSIX Path seemed to work for the SetDirectoryURL method to actually take the user to the proper location. I also forgot to mention this script needs to run as part of a Filemaker "Perform Applescript" step which, I assume, compile Applescript inside Filemaker on the fly as it executes the script step.

My new approach is pretty kludgey, but here is my proof of concept:
  1. I created a "helperApp.app" that has a handler I can call to get the openPanel passing an argument with the directory I want to show in the openPanel (I may end up exposing more parameters so it is fully customizable). Passing a POSIX path like "/Users/jim/Movies" works. Sending a URL (e.g., "file://localhost/Users/jim/Movies/") does not work. I can only assume there's some translation going on there between AppleScript and Obj-C? The helper app returns either an empty list (if cancel is pressed) or returns a list of POSIX paths of what was selected. It will have ASObjC Runner embedded in the Resource folder.
  2. In the script, I call the helper app to get the results.
Does running Applescript Objective-C natively in an Applescript script get easier in OS X 10.8+? I'm stuck in OS X 10.6 for now due to production reasons, but I'm hoping the state of things for executing ASObjC gets simpler, or is the ASObjC Runner my best option to pass ASObjC snippets inside vanilla Applescript? If so, maybe this openPanel function could be added to it as native functionality? Shane?

This is what my code looks like:

Filemaker code snippet

tell application "helperApp"

launch

set x to someHandler("/path/to/directory/to/open")

end tell



helperApp.app

on someHandler(theDir)

script OpenPanelAcceptingFilesAndFolders

set thePanel to current application's NSOpenPanel's openPanel()

set theDir to current application's NSApp's passedValue() as text

tell thePanel

setMessage_("Please choose client files. Cmd-Click to select more than one file/folder.")

setTitle_("Client Files Collect")

setFloatingPanel_(true)

setShowsHiddenFiles_(false)

setTreatsFilePackagesAsDirectories_(false)

setDirectoryURL_(theDir)

setCanChooseFiles_(true)

setCanChooseDirectories_(true)

setAllowsMultipleSelection_(true)

set returnCode to runModal()

end tell

set returnCode to returnCode as integer

set theResults to {}

if returnCode = (current application's NSFileHandlingPanelOKButton) as integer then

set theURLs to thePanel's URLs() as list

repeat with i from 1 to count of theURLs

tell item i of theURLs to set thePosixPath to |path|()

set theResults to theResults & thePosixPath

end repeat

end if

return theResults

end script

set x to {}

using terms from application "ASObjC Runner"

set runnerPath to (path to resource "ASObjC Runner-N.app") as text

tell application runnerPath

set x to run the script {OpenPanelAcceptingFilesAndFolders} passing theDir with response

end tell

end using terms from

return x

end someHandler

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: openPanel using Automator Runner
      • From: Shane Stanley <email@hidden>
References: 
 >Re: openPanel using Automator Runner (From: Jim Skibbie <email@hidden>)

  • Prev by Date: use applescript to import contacts
  • Next by Date: Re: openPanel using Automator Runner
  • Previous by thread: Re: openPanel using Automator Runner
  • Next by thread: Re: openPanel using Automator Runner
  • Index(es):
    • Date
    • Thread