Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Creating UIs with AppleScript

Explorer ,
Jan 26, 2018 Jan 26, 2018

So I am working on some scripts for work and looking at both javascript and AppleScript. Now the main problem I have come up against is there a way to create UI pop ups in AppleScript. I have created a script UI that we can set all the options on export, but how would I do this with apple since that is Java-based.

TOPICS
Scripting
5.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Jan 26, 2018 Jan 26, 2018

With applescript, unfortunately they only let you do so much before you have to jump into some development program and create a special UI application just for the applescript.

The basic overview:

Mac Automation Scripting Guide: Prompting for a Choice from a List

With the basics arsenal you can at least create some kind of advanced ui by using perhaps a series of pop-ups.

As williamadowling​ points out, the most convenient way is to use ExtendScript's ScriptUI. You find the reference documentation

...
Translate
Adobe
Community Expert ,
Jan 26, 2018 Jan 26, 2018

Just curious, why can't you use javascript to create your popups? With javascript, it's quite easy to send an alert, like so:

alert("String to display to user.");

or are you talking about using ScriptUI to send a custom alert message? If that's the case, you can do that with a custom javascript function like so:

function customAlert(msg)

{

    var ca = new Window("dialog");

        var alertMsg = ca.add("statictext", undefined, msg);

        var okBtn = ca.add("button", undefined, "Ok");

            okBtn.onClick = function()

            {

                ca.close();

            }

    ca.show();

}

customAlert("This is a custom alert message.");

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 29, 2018 Jan 29, 2018

I am training someone at work on scripting. I know javascript, but they might be better at learning AppleScript as a beginner. So maybe my best bet is to teach them apple then slide into Javascript when we get into more complicated things..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 26, 2018 Jan 26, 2018

With applescript, unfortunately they only let you do so much before you have to jump into some development program and create a special UI application just for the applescript.

The basic overview:

Mac Automation Scripting Guide: Prompting for a Choice from a List

With the basics arsenal you can at least create some kind of advanced ui by using perhaps a series of pop-ups.

As williamadowling​ points out, the most convenient way is to use ExtendScript's ScriptUI. You find the reference documentation by Peter Kahrel at ScriptUI for dummies | Peter Kahrel

If you want to do something that applescript can do and not extendscript, from extendscript, do not worry- there are ways to use your jsx UI and then later execute an applescript.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 29, 2018 Jan 29, 2018

I have used Script UI to do more complicated things. I would have hoped that AppleScript had a similar thing.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 29, 2018 Jan 29, 2018

i learned how to code by writing little snippets for illustrator, and eventually turned that into my full time job. I started with applescript because, to me, it seemed easier to pick up. And i found myself immensely frustrated every day. The syntax is less intuitive than it looks for a newbie.

I you're teaching someone how to write scripts, then I think the bulk of what you're teaching is just logic. The logic is the same for either language, but applescript only scratches the surface of what illustrator can do. I think it's prudent to go straight into javascript and skip the future transition period between applescript and javascript whenever your colleague learns that applescript is going to hold them back.

just my $.02

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 29, 2018 Jan 29, 2018
LATEST

I do agree. Whatever the targeted app, ExtendScript first. Applescript or VisualBasic have their pros but only for specific pieces of code. In InDesign, you have that ability of calling AS/VB from your code but I don't think other Adobe apps allow that.

Once that said, you could use AS only as a starter and where you need to communicate with other apps (I mean Excel or whatever), and use "do javascript" to run ExtendScript code. That's worth when it makes sense.

For scripts that stick to the app itself, just go ExtendScript.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines