Skip to main content
Inspiring
April 28, 2017
Question

Create popup warning that autocloses

  • April 28, 2017
  • 2 replies
  • 1885 views

Hi

I'm trying to pop up a warning dialog for 2 seconds then have it close.

The following code works:

var w = new Window ("palette","test", [200, 200, 680, 325], {resizeable: false});  

w.show(); 

alert("hi");

w.close();

but obviously doesn't autoclose

var w = new Window ("palette","test", [200, 200, 680, 325], {resizeable: false});  

w.show(); 

 

//delay(2);

$.sleep(2000);

 

w.close();

function delay(prmSec){

  prmSec *= 1000;

  var eDate = null;

  var eMsec = 0;

  var sDate = new Date();

  var sMsec = sDate.getTime();

  do {

  eDate = new Date();

  eMsec = eDate.getTime();

  } while ((eMsec-sMsec)<prmSec);

  }

using either delay or sleep the palette only shows up occasionally (every third run of the script...)

1) any idea WHY it doesn't show up reliably?

2) is there a better way to make a popup?

thanks

This topic has been closed for replies.

2 replies

Community Expert
May 25, 2023

@akiva_atwood said: "I've noticed other graphic glitches with the last update to CC2015 -- text vanishes on the screen, and I have to force a redraw to see it again)"

 

Hi @akiva_atwood ,

just tested the "palette" type of window without using update() on Windows 10.

Ran the script from InDesign's Scripts panel. No issue with my German InDesign CS6 version 8.1.0 or InDesign 2023 version 18.1.0.51.

 

#targetengine autoCloseAlert

var sleepPeriodInSeconds = 2;
var sleepPeriodAsString = " " + sleepPeriodInSeconds + " ";
 
var dlog = new Window("palette"); 
dlog.size = [320,100]; 
dlog.add("statictext", undefined , "We are closing in"+ sleepPeriodAsString +"seconds.");
dlog.show();

// Is that necessary? :
//~ dlog.update();
// Perhaps on some versions of macOS together with some specific versions of InDesign?

// Have a nap:
$.sleep(sleepPeriodInSeconds * 1000);

// Closing the dialog: 
dlog.close();

 

Regards,
Uwe Laubender
( Adobe Community Expert )

tpk1982
Legend
April 28, 2017

If i tested in Extendscript then it work good..

Inspiring
April 28, 2017

I know. But in Indesign it doesn't.

(I'm using CC2015 on a mac in case that's part of the problem)

Community Expert
April 28, 2017

Hi,

did you run it from the ESTK addressing InDesign?

Do not run it from the ESTK.
Run it by double-click from InDesign's Scripts panel.

Another example that is working for me with my German InDesign CC 2017.1 on German Mac OSX 10.10.5
( started from the Scripts panel… )

var dlog = new Window("palette");

dlog.size = [320,100];

dlog.add("statictext", undefined , "We are closing in 2 seconds.");

dlog.show();

// Have a nap:

$.sleep(2000);

// Closing the dialog:

dlog.close();

Regards,
Uwe