Skip to main content
jasonp49818280
Inspiring
January 26, 2018
Answered

Creating UIs with AppleScript

  • January 26, 2018
  • 2 replies
  • 6023 views

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.

This topic has been closed for replies.
Correct answer Silly-V

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.

2 replies

Silly-V
Silly-VCorrect answer
Legend
January 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.

jasonp49818280
Inspiring
January 29, 2018

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

Disposition_Dev
Legend
January 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

Disposition_Dev
Legend
January 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.");

jasonp49818280
Inspiring
January 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..