Skip to main content
Inspiring
May 10, 2019
Question

Script Alert - Title - Alert Box

  • May 10, 2019
  • 2 replies
  • 15304 views

Ive noticed that when doing something like...

alert("Your message here..."); in Windows, the alert box shows Script Alert as the title but Mac doesn't

Is there anyway to replace the Script Alert with something else or is it just a Windows thing?

This topic has been closed for replies.

2 replies

Stephen Marsh
Community Expert
Community Expert
May 10, 2019

https://estk.aenhancers.com/8%20-%20ExtendScript%20Tools%20and%20Features/user-notification-dialogs.html

Global alert function

Displays a platform-standard dialog containing a short message and an OK button.

alert()

alert (message[, title, errorIcon]);

messageThe string for the displayed message.
titleOptional. A string to appear as the title of the dialog, if the platform supports a title. Mac OS does not support titles for alert dialogs. The default title string is “Script Alert.”
errorIconOptional. When true, the platform-standard alert icon is replaced by the platform-standard error icon in the dialog. Default is false.

Returns undefined

schroef
Inspiring
December 18, 2020

Ohmygod how horrendous is the Windows dialog compared to OSX.

THe UI is completely off. OSX shows same theme as the app, windows does not. Also uses with margins and ugle ! icon 😞

Stephen Marsh
Community Expert
Community Expert
December 23, 2020

It's a platform standard dialog, so you get what you get.

 

You could use scriptUI to create a subjectively better looking alert... At least it will be "more consistent" from Mac to Win.

 

 

Here is a function that can be used once, with a variable call to change the alert text multiple times if needed.

 

https://gist.github.com/MarshySwamp/9b23cfeb128ab6652164d6d87268bc6a

 

scriptAlert("Alert window title", "Alert text string 1", "Alert text string 2");

function scriptAlert(alertTitle, alertString1, alertString2) {
    var alertWindow = new Window("dialog", undefined, undefined, {resizeable: false});
        alertWindow.text = alertTitle;
        alertWindow.preferredSize.width = 300;
        alertWindow.preferredSize.height = 100;
        alertWindow.orientation = "column";
        alertWindow.alignChildren = ["center", "top"];
        alertWindow.spacing = 25;
        alertWindow.margins = 20;
    var alertText = alertWindow.add("group");
        alertText.orientation = "column";
        alertText.alignChildren = ["left", "center"];
        alertText.spacing = 0;
        alertText.alignment = ["left", "top"];
        alertStringSize1 = alertText.add("statictext", undefined, alertString1, {name: "alertText", multiline: true});
        alertStringSize1.graphics.font = ScriptUI.newFont ("dialog", "BOLD", 13);
        alertStringSize2 = alertText.add("statictext", undefined, alertString2, {name: "alertText", multiline: true});
        alertStringSize2.graphics.font = "dialog:13";
    var okButton = alertWindow.add("button", undefined, undefined, {name: "okButton"});
        okButton.text = "OK";
        okButton.alignment = ["left", "top"];
        okButton.graphics.font = "dialog:13";
    
    alertWindow.show();
}

 

Edit: I have updated the code to increase the size of the text so that the text size is more legible on Win OS. I'm still trying to work out the correct syntax for the menu title size... Can anybody help?

 

Based on code generated from ScriptUI Dialog Builder with some tweaks based on Peter Kahrel's "Bible" – Beginning ScriptUI

Tom Winkelmann
Inspiring
May 10, 2019

Don't know Mac, but you can try something like this...

alert("Your message here...", "Whateveryouwant");