Skip to main content
December 12, 2019
Answered

Pause the script while showing a message

  • December 12, 2019
  • 1 reply
  • 1198 views

Hi all,

I can pause a script for a short while using $.sleep(1000) but is there any way to display a messsage while it is paused without having to "OK" the message, it just disappears when the script continues?

Many Thanks, Bren

This topic has been closed for replies.
Correct answer brian_p_dts
Disregard previous. You can use the Window object. Window and sleep don't always get along, so I might do something like this: 

(Edit: Try TaW's method below, which is *much* more efficient -- though I was having some issues getting the window to stick with sleep). 

 

 

 

var w = new Window("window", "header");
var t = w.add ("statictext", undefined, "A longer message goes here");
var i = 0;
while (i < 30000) {
    w.show();
    i++
}
w.close();

 

 

 

 

 

 

 

1 reply

brian_p_dts
Community Expert
brian_p_dtsCommunity ExpertCorrect answer
Community Expert
December 12, 2019
Disregard previous. You can use the Window object. Window and sleep don't always get along, so I might do something like this: 

(Edit: Try TaW's method below, which is *much* more efficient -- though I was having some issues getting the window to stick with sleep). 

 

 

 

var w = new Window("window", "header");
var t = w.add ("statictext", undefined, "A longer message goes here");
var i = 0;
while (i < 30000) {
    w.show();
    i++
}
w.close();

 

 

 

 

 

 

 

TᴀW
Legend
December 12, 2019

Whoah, I wouldn't do that! You're showing() the window 30000 times in that loop unnecessarily!

Use a "palette" type window instead, like this, for a 3 second pop-up message:

var w = new Window("palette");
w.add("staticText", undefined, "Hello World!");
w.show();
$.sleep(3000);
w.close();
Visit www.id-extras.com for powerful InDesign scripts that save hours of work — automation, batch tools, and workflow boosters for serious designers.
brian_p_dts
Community Expert
Community Expert
December 12, 2019

When I tried to test with sleep: the sleep function ran, and the palette only appeared toward the end of the sleep for a fraction of a second before disappearing. Maybe there's just something off with my sleep, but it always causes more problems than it solves in my experience, though I agree my solution is...wasteful.