Skip to main content
Known Participant
June 22, 2018
Answered

Alert() or Notification for set time

  • June 22, 2018
  • 2 replies
  • 1832 views

Hi

We are using scripts to auto design.

There is a load time of around 3-5 seconds to complete the script and all of the changes.

At present we have an alert() box which notifies once edits have been completed.

The issue is it requires a click and an extra step.

Is there a way to display a notification for example for 1 second and then it disappears.

Almost like a timed alert() but without the OK button or ok button disabled?

In standard javascript i would use something like

setTimeout( function ( ) { alert( "Design Complete!" ); }, 1000 ); //displays msg in 10 seconds

Thanks

This topic has been closed for replies.
Correct answer r-bin

warn("Design Complete!", 2000)

var msg = warn("Design Complete!", 0)

// alert()

// some code

// $.sleep(1000)

msg.close()

function warn(str, del)

    {

    try {

        var msg = new Window("palette", "", undefined, {resizeable: false, minimizeButton:false, maximizeButton: false, closeButton: false, closeOnKey: false} );

        msg.margins = [0, 10, 0, 10];

        msg.orientation = "column";

        msg.alignChildren = "center";

        msg.txt = msg.add("statictext", undefined, str);

        msg.txt.justify = "center";

        msg.onShow = function()

            {

            var min_len = 132;   

            var off = 2;   

            var xx = 60 +2*off;

            msg.layout.layout(true);

            var txt_width = msg.txt.size.width;

            msg.txt.bounds[0] = off;

            msg.txt.bounds[2] = txt_width + xx - 2*off;

            if (msg.txt.bounds[2] < min_len) msg.txt.bounds[2] = min_len;

            msg.layout.layout(true);

            }

        msg.show();

       

        if (del == undefined) del = 1000;

        if (del)

            $.sleep(del);

        else

            return msg;

   

        msg.close();               

        msg = null;

        }

    catch (e) { alert(e); throw(e); }

    }  

2 replies

r-binCorrect answer
Legend
June 22, 2018

warn("Design Complete!", 2000)

var msg = warn("Design Complete!", 0)

// alert()

// some code

// $.sleep(1000)

msg.close()

function warn(str, del)

    {

    try {

        var msg = new Window("palette", "", undefined, {resizeable: false, minimizeButton:false, maximizeButton: false, closeButton: false, closeOnKey: false} );

        msg.margins = [0, 10, 0, 10];

        msg.orientation = "column";

        msg.alignChildren = "center";

        msg.txt = msg.add("statictext", undefined, str);

        msg.txt.justify = "center";

        msg.onShow = function()

            {

            var min_len = 132;   

            var off = 2;   

            var xx = 60 +2*off;

            msg.layout.layout(true);

            var txt_width = msg.txt.size.width;

            msg.txt.bounds[0] = off;

            msg.txt.bounds[2] = txt_width + xx - 2*off;

            if (msg.txt.bounds[2] < min_len) msg.txt.bounds[2] = min_len;

            msg.layout.layout(true);

            }

        msg.show();

       

        if (del == undefined) del = 1000;

        if (del)

            $.sleep(del);

        else

            return msg;

   

        msg.close();               

        msg = null;

        }

    catch (e) { alert(e); throw(e); }

    }  

web2000Author
Known Participant
June 22, 2018

Thanks that worked

web2000Author
Known Participant
June 22, 2018

Ok understood. Is there a way to disable or make photoshop non responsible until script is complete?