Skip to main content
Participant
February 15, 2023
Question

[js] dialog or palette - not show up

  • February 15, 2023
  • 1 reply
  • 1105 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);

Loic.Aigon
Legend
February 17, 2023

Not certain setTimeout is part of ExtendScript if we are talking about ScriptUI here.

There is $.sleep(3000); that you can use for closing your window after 3 seconds but your problem would be that the app would be in modal state for that long(i.e. user can't use the app) 😕😕

 

Community Expert
February 17, 2023

Thanks for the tip! I see what you mean!