Skip to main content
Participant
February 15, 2023
Question

[js] dialog or palette - not show up

  • February 15, 2023
  • 1 reply
  • 1110 views

Hi, habe problem with script. 
need open a window with some information, which will automatically disappear after 3 seconds.
my code:

 

#targetengine "session"
var windowX = new Window("dialog"); // v2 palette
    windowX.orientation = "row"; 
    windowX.preferredSize.width = 200; 
    windowX.preferredSize.height = 200; 
    windowX.alignChildren = ["center","center"]; 
    windowX.spacing = 15; 
    windowX.margins = 16; 
    
var image1_imgString = "%C2%89PNG%0D%0A%1A..."
var image1 = windowX.add("image", undefined, File.decode(image1_imgString), {name: "image1"}); 
    windowX.show();

dialog show, palette not

if I add ... 

var timerBreak = new Date().getTime() + 3000;
var now = new Date().getTime();
    while(now<timerBreak){
          now = new Date().getTime()
    }
    windowX.close();

nothing happend (happend: first: loop, next: window show and close at the same time) - why?
if i add ...

windowX.addEventListener('show',function(){
             ...
}

same ... 
but if i add alert("dhgkjsd") to check ... dialog or palette show and wait for click on messagaebox

how to make a timer that will close the displayed window 3 seconds after opening?

 

This topic has been closed for replies.

1 reply

Community Expert
February 16, 2023

I think it's the 'while' function

Try 

 

setTimeout()

 

Maybe this isn't 100% correct but 

 

#targetengine "session"

var windowX = new Window("palette");
windowX.preferredSize.width = 200;
windowX.preferredSize.height = 200;

var image1_imgString = "%C2%89PNG%0D%0A%1A...";
var image1 = windowX.add("image", undefined, File.decode(image1_imgString), {name: "image1"});

windowX.show();

setTimeout(function() {
windowX.close();
}, 3000);

TomTom_78Author
Participant
February 20, 2023

err no:24 : setTimeout is not a function

Community Expert
February 20, 2023

That's my fault - I didn't realise settimeout is not a function.

 

You might find the corret property here 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ConditionalTextPreference.html#d1e421085