Skip to main content
aruncarun
Participant
October 26, 2017
Answered

auto close alert message

  • October 26, 2017
  • 1 reply
  • 2896 views

Hello everyone ,

i need a script to close alert after 5 seconds automatically. in extend script toolkit please help me .

Thanks and regards,

Arun

This topic has been closed for replies.
Correct answer O2 Creative NZ

You have to create your own palette window. Example below


customAlert('Hello', 3, 'This is a test - Will close in 3 seconds')
customAlert('Hello', 0, 'This is a test - Will not close automatically')

function customAlert(message, delaySeconds, title){
    title = title || 'Alert';
    var alertWindow = new Window('palette', title);
    var control_text = alertWindow.add('edittext', [0, 0, 500, 200], message, {multiline: true});
   
    if(delaySeconds == 0){
        var control_close = alertWindow.add('button', undefined, 'Close');       
        control_close.onClick = function(){
            if(alertWindow){
                alertWindow.hide();
            }
        };
    }

    alertWindow.show();
    alertWindow.update();
   
    if(delaySeconds > 0){
        $.sleep(delaySeconds * 1000);
        alertWindow.hide();
        alertWindow = null;
    }  
}

Glenn

o2 Creative

1 reply

O2 Creative NZCorrect answer
Inspiring
October 26, 2017

You have to create your own palette window. Example below


customAlert('Hello', 3, 'This is a test - Will close in 3 seconds')
customAlert('Hello', 0, 'This is a test - Will not close automatically')

function customAlert(message, delaySeconds, title){
    title = title || 'Alert';
    var alertWindow = new Window('palette', title);
    var control_text = alertWindow.add('edittext', [0, 0, 500, 200], message, {multiline: true});
   
    if(delaySeconds == 0){
        var control_close = alertWindow.add('button', undefined, 'Close');       
        control_close.onClick = function(){
            if(alertWindow){
                alertWindow.hide();
            }
        };
    }

    alertWindow.show();
    alertWindow.update();
   
    if(delaySeconds > 0){
        $.sleep(delaySeconds * 1000);
        alertWindow.hide();
        alertWindow = null;
    }  
}

Glenn

o2 Creative

aruncarun
aruncarunAuthor
Participant
October 26, 2017

Thank you so much sir!!!