Skip navigation
Currently Being Moderated

Palette Window Display Time

Jul 18, 2012 12:08 PM

Hey guys,

 

Is there a way to have a palette window display for a certain duration while the script continues to run in the background?  Basically, I want a form of alert window that doesn't pause the script while it's up.  It doesn't have to be a palette window, but that's the only thing I can think of that would work for this.  If you have any ideas for other kinds of windows that could do this, I'd be open to that as well.  It just basically needs to be a window that will come up and tell the user that no errors were found in their naming and it is now saving their work, staying up long enough to read, then closing itself.  Thanks in advance for any help!

 

dgolberg

 
Replies
  • JJMack
    3,425 posts
    Jan 9, 2006
    Currently Being Moderated
    Jul 18, 2012 1:42 PM   in reply to dgolberg
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 19, 2012 7:51 AM   in reply to dgolberg

    I don’t know if there’s a proper way to do this, but one can getTime() before showing the window, then set up a while function to compare the current time with that and close the window if a certain difference has been reached.

    But that would effectively halt the Script for the duration and seems a somewhat brute approach.

     

    Edit: Instead of a while function I guess one could also check for the passed time at later positions in the Script, but who knows if that’s a good idea?

    Edit 2: It seems to work, though; Photoshop can execute (at least some) Script commands while the window is open.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 19, 2012 11:34 PM   in reply to dgolberg

    Well, like I said in an edit to the message it seems to work.

    Not sure if it’s wise to  do it thusly, though.

    // 2012, use it at your own risk;

    #target photoshop

    var w = new Window('palette','Check Complete', [500,300,820,850]);

     

     

    var now = new Date();

    var thisTime = now.getTime();

     

     

    var ret = w.show();

     

     

    var myDocument = app.documents.add(new UnitValue(2000, "px"), new UnitValue(2000, "px"), 300, "test", NewDocumentMode.RGB, DocumentFill.TRANSPARENT);

    myDocument.selection.selectAll();

     

     

    checkTime (thisTime);

     

     

    myDocument.selection.fill(app.foregroundColor, ColorBlendMode.NORMAL, 100, false);

     

     

    checkTime (thisTime);

     

     

    myDocument.layers[0].applyClouds();

     

     

    checkTime (thisTime);

     

     

    myDocument.selection.deselect();

     

     

    checkTime (thisTime);

     

     

    check = true;

    while (check == true) {

    var now2 = new Date();

    var thisTime2 = now2.getTime();

    if (thisTime2 > thisTime + 1000) {

              check = false;

              try {w.close()} catch (e) {}

              }

    };

     

     

    ////////////////////////////////////

    function checkTime (thisTime) {

    var now2 = new Date();

    var thisTime2 = now2.getTime();

    if (thisTime2 > thisTime + 1000) {w.close()}

    };

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 21, 2012 4:47 AM   in reply to dgolberg

    Maybe you should wait for more feedback … because this approach seems a bit strange.

    Have you also asked over at http://ps-scripts.com/bb/ ?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points