• 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: integrating AppleScript and ScriptUI in Adobe Illustrator/InDesign?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: integrating AppleScript and ScriptUI in Adobe Illustrator/InDesign?


  • Subject: Re: integrating AppleScript and ScriptUI in Adobe Illustrator/InDesign?
  • From: has <email@hidden>
  • Date: Mon, 16 Mar 2015 22:13:06 +0000

On 13/03/2015 23:10, Shane Stanley wrote:
On 14 Mar 2015, at 1:24 am, has <email@hidden> wrote:

if anyone's got any other suggestions

You could always bite your tongue and do it in ASObjC. The Dialog Toolkit script I posted here a while back is a pretty decent example of hacking NSAlert by adding an accessory view containing whatever you want, and it can be run from ID's Scripts Panel and AI's lame Scripts submenu without any of the panel disappearing business. You can download a more recent version from the bottom of this page: <http://www.macosxautomation.com/applescript/apps/>. You can also load your own NIBs and do it that way.
<snip nice looking example>

Hi Shane,

Cheers for the suggestion and the link for your Dialog Toolkit library. Alas, Dialog Toolkit won't help me on this occasion as I require a data-driven approach (c.f. Dialog Director osax), not a code-driven approach. The goal is to allow a Manta Toolkit user to pick a random rule, then auto-generate a nice GUI input form where the user can enter the values for that rule instead of having to type the entire command into a CLI (which isn't hard, but Terminal's a bit scary for new users). For example, if the user tells Manta Toolkit to do a `run tutorial` job [1][2], MT goes off and looks up the rule's interface description:

    run tutorial (use rows, spreadsheet name)

        use rows : list of whole number of 2 or more [optional] — the spreadsheet row(s) to run; if omitted, all rows are processed
        spreadsheet name : text [default: "tutorial.packcopy.xlsx"] — the pack copy to use (this is the spreadsheet file's name)

Based on that information, it generates a JSON form [3] description containing input controls for each value, plus the standard OK and Cancel buttons:

{
    "title": "run tutorial",
    "schema": {
        "1": {"type": "string", "title": "use rows"},
        "2": {"type": "string", "title": "spreadsheet name"}
    },
    "form": [
        {"key": "1", "description": "the spreadsheet row(s) to run [...]"},
        {"key": "2", "description": "[...]", "placeholder": "tutorial.packcopy.xlsx"},
        {"type": "submit", "title": "OK"},
        {"type": "button", "title": "Cancel", "onClick": "user canceled"}
    ]
}

Once the form description's done it displays the form in a WebView, allowing the user to enter their values into the form. On clicking OK, the entered values are extracted from the returned form data, and the finished rule command constructed; e.g. if the user specifies row 4 of the "foo.xlsx" spreadsheet, the following ready-to-use rule command is produced:

    run tutorial (4, foo.xlsx)

Currently it only does basic text fields but eventually it'll choose different types of controls depending on the type of value required (e.g. an enum might appear as radio buttons, a date as a date chooser, etc) and include tooltip descriptions and any validation requirements as well (e.g. value must be an integer ≥2). The JSON form library's not ideal but it should do for now; it's the focus stealing that's the biggest annoyance.


FWIW, I did wonder if your suggestion could be adapted so that an attached AppleScript would create an empty NSPanel within AI, then add controls according to the requirements supplied by MT. The problem there is that MT also sometimes needs to display further dialogs while it's running [4], which means that not only would the AI-attached Applescript need to run MT, but MT would need to send messages to attached AppleScript as well. But as you say, AI's attachability is weak (it's no Smile), and I don't think it's possible to run an attached script via AppleScript, only by clicking it in the Scripts palette; plus AS is not great for non-blocking/asynchronous.

Packaging the NSPanel as an ObjC++ plugin might be a possibility as AI provides more extensive APIs for that. OTOH AI's crashy enough already without my C* code destabilizing it too, so will need to think about that. Anyway, it's given us something to chew on further.

Thanks,

has


[1] http://mantasystems.co.uk/documentation/rule-descriptions/templating_tutorial/rules/run_tutorial.html

[2] Configuring and running `run tutorial` job via an auto-generated form: http://mantasystems.co.uk/runtutorial-720.mov (4MB, no audio)

[3] JSON form library docs: https://github.com/joshfire/jsonform/wiki

[4] Inserting pack copy (plus tags) to create lead artwork, then auto-generating child artworks from that [5]: http://mantasystems.co.uk/placepackcopy-720.mov (22MB, no audio)

[5] The assisted pack copy placement's another Shane suggestion; the automagic "replay" is one of mine.;)



 _______________________________________________
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

References: 
 >integrating AppleScript and ScriptUI in Adobe Illustrator/InDesign? (From: has <email@hidden>)

  • Prev by Date: Re: Cannot save line break literal in AppleScript editor
  • Next by Date: Re: Cannot save line break literal in AppleScript editor
  • Previous by thread: integrating AppleScript and ScriptUI in Adobe Illustrator/InDesign?
  • Next by thread: Can't Coerce String to Date?
  • Index(es):
    • Date
    • Thread