if i change palette it works automatic and cancel button does not work...
I w
var run = true
var dlg = new Window('palette')
dlg.cancelBtn = dlg.add('button',undefined,'Cancel')
dlg.cancelBtn.onClick = function(){run = false; dlg.close();}
dlg.cancelElement = dlg.cancelBtn; // do it if name != 'Cancel'
dlg.show();
if(run){
//Code is Run Automatic When Script is run
alert("your code");
}
It works. Only the script takes away all the resources of Photoshop, and there is no time left to process the click. Put Actions in StepByStep mode or use refresh() from time to time.
var time0 = $.hiresTimer;
var time = time0;
var run = true
var dlg = new Window('palette')
dlg.cancelBtn = dlg.add('button',undefined,'Cancel')
dlg.cancelBtn.onClick = function(){run = false}
dlg.show();
while(run){
app.beep(1000);
$.sleep(200);
time += $.hiresTimer;
if (time > 2000000) { time = $.hiresTimer; refresh(); }
}
Or use doProgress.
doForcedProgress("the script", "f()");
function f()
{
while (1)
{
if (!app.updateProgress(0,0)) return;
app.beep(1000);
$.sleep(200);
}
}