cs2 force screen redraw

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Mike Hale

cs2 force screen redraw

Post by Mike Hale »

Hi X,

My play back option is set to accelerated and the screen is still refreshed when I move a dialog that is over an image.

But you are right in that while most scripts are running, that is not waiting on a dialog, the screen is not refreshed.
Timo Autiokari

cs2 force screen redraw

Post by Timo Autiokari »

Mike, so far I've tested this on 5 computers and they all behave the same (all my Actions are in Accelerated mode).

So, when a Script shows a custom UI dialog (waiting for the for user input) and this dialog is on top a document, and I move that dialog, then redraw _never_ happens. I can use the dialog to "wipe" all the document so that it looks like Opaque 0% all over. The behavior is the same no matter if I start the Script from an Action button or from the File/Scripts menu.

Do I understand correctly that in the above mentioned situation you do get the redraw properly?

When an Action shows a built-in CS2 dialog, and I move that dialog, then the screen always does redraw properly.

Thank you,
Timo Autiokari
Timo Autiokari

cs2 force screen redraw

Post by Timo Autiokari »

Oh, could there be something wrong with my custom dialogs, I have very similar structure with all of them. Below is one test, could you please test with it, take it to ESTK, save as jsx and then run. When I hoover with the dialog the doc goes to what looks 0% Opacity but also the CS2 palettes go gray (less input-boxes and window frames).

Code: Select allalarm("This is a test dialog for screen redraw. Drag all over the active document and also over the various CS2 tools palettes.");


function alarm(txt){
alarmdialog = new Window('dialog');
alarmdialog.orientation = 'column';
alarmdialog.margins = 10;
alarmdialog.text = "ALERT: " + getScriptName();

var alarmgroup = alarmdialog.add('group');
alarmgroup.alignChildren = 'left';
alarmgroup.orientation = 'row';

//var icon = alarmgroup.add('image', undefined, File(getScriptPath() + "/alarmicon.png"));

var alarmtxt = alarmgroup.add("statictext",undefined ,"", {multiline:true});
alarmtxt.text = txt;

var buttonsgroup = alarmdialog.add('group');
buttonsgroup.alignChildren = 'left';
buttonsgroup.orientation = 'row';

var okButton = buttonsgroup.add('button');
okButton.text = 'OK';
okButton.name ='ok';
okButton.size = [60,20];
okButton.onClick =function (){
this.parent.parent.close(1);
}

alarmdialog.center();
alarmdialog.show();
WaitForRedraw();
}


function WaitForRedraw(){;
var eventWait = charIDToTypeID('Wait');
var enumRedrawComplete = charIDToTypeID('RdCm');
var typeState = charIDToTypeID('Stte');
var keyState = charIDToTypeID('Stte');
var desc = new ActionDescriptor();
desc.putEnumerated(keyState, typeState, enumRedrawComplete);
executeAction(eventWait, desc, DialogModes.NO);
}

function getScriptFile(){
var dbLevel = $.level;
$.level = 0;
var path = undefined;
try {
some_undefined_variable;
} catch (e) {
path = e.fileName;
}
$.level = dbLevel;
return new File(path);
};

function getScriptName(){
return decodeURI(getScriptFile().name);
}

function getScriptPath(){
return getScriptFile().path;
}



Timo Autiokari
Timo Autiokari

cs2 force screen redraw

Post by Timo Autiokari »

Aha. I found it, code below. Every so often here I feel I'm missing a property...

X.verbose;

I have always had the Action Properties in Accelerated, and I have had the belief that it would be a per Action property. But it is a general overall setting.

Btw, when I was capturing the below goAccelerated() and goStepByStep() code with SL I was absolutely sure that I will be getting an error message saying something like Action options can not be changed while an Action is running. But it works! Phew, now I only need to add these around all the dialogs in my scripts.

Again thank you X, without your above post I would never had tried.

Code: Select all//save as jsx, then run and see the difference

goStepByStep();
alarm("StepByStep test dialog for screen redraw, move this dialog around.");

goAccelerated();
alarm("Accelerated test dialog for screen redraw, move this dialog around.");

function alarm(txt){
alarmdialog = new Window('dialog');
alarmdialog.orientation = 'column';
alarmdialog.margins = 10;
alarmdialog.text = "ALERT: " + getScriptName();

var alarmgroup = alarmdialog.add('group');
alarmgroup.alignChildren = 'left';
alarmgroup.orientation = 'row';

//var icon = alarmgroup.add('image', undefined, File(getScriptPath() + "/alarmicon.png"));

var alarmtxt = alarmgroup.add("statictext",undefined ,"", {multiline:true});
alarmtxt.text = txt;

var buttonsgroup = alarmdialog.add('group');
buttonsgroup.alignChildren = 'left';
buttonsgroup.orientation = 'row';

var okButton = buttonsgroup.add('button');
okButton.text = 'OK';
okButton.name ='ok';
okButton.size = [60,20];
okButton.onClick =function (){
this.parent.parent.close(1);
}

alarmdialog.center();
alarmdialog.show();
WaitForRedraw();
}


function WaitForRedraw(){;
var eventWait = charIDToTypeID('Wait');
var enumRedrawComplete = charIDToTypeID('RdCm');
var typeState = charIDToTypeID('Stte');
var keyState = charIDToTypeID('Stte');
var desc = new ActionDescriptor();
desc.putEnumerated(keyState, typeState, enumRedrawComplete);
executeAction(eventWait, desc, DialogModes.NO);
}

function getScriptFile(){
var dbLevel = $.level;
$.level = 0;
var path = undefined;
try {
some_undefined_variable;
} catch (e) {
path = e.fileName;
}
$.level = dbLevel;
return new File(path);
};

function getScriptName(){
return decodeURI(getScriptFile().name);
}

function getScriptPath(){
return getScriptFile().path;
}


function goAccelerated(){
var id82 = charIDToTypeID( "setd" );
var desc18 = new ActionDescriptor();
var id83 = charIDToTypeID( "null" );
var ref13 = new ActionReference();
var id84 = charIDToTypeID( "Prpr" );
var id85 = charIDToTypeID( "PbkO" );
ref13.putProperty( id84, id85 );
var id86 = charIDToTypeID( "capp" );
var id87 = charIDToTypeID( "Ordn" );
var id88 = charIDToTypeID( "Trgt" );
ref13.putEnumerated( id86, id87, id88 );
desc18.putReference( id83, ref13 );
var id89 = charIDToTypeID( "T   " );
var desc19 = new ActionDescriptor();
var id90 = stringIDToTypeID( "performance" );
var id91 = stringIDToTypeID( "performance" );
var id92 = stringIDToTypeID( "accelerated" );
desc19.putEnumerated( id90, id91, id92 );
var id93 = charIDToTypeID( "PbkO" );
desc18.putObject( id89, id93, desc19 );
executeAction( id82, desc18, DialogModes.NO );
}


function goStepByStep(){
var id97 = charIDToTypeID( "setd" );
var desc21 = new ActionDescriptor();
var id98 = charIDToTypeID( "null" );
var ref15 = new ActionReference();
var id99 = charIDToTypeID( "Prpr" );
var id100 = charIDToTypeID( "PbkO" );
ref15.putProperty( id99, id100 );
var id101 = charIDToTypeID( "capp" );
var id102 = charIDToTypeID( "Ordn" );
var id103 = charIDToTypeID( "Trgt" );
ref15.putEnumerated( id101, id102, id103 );
desc21.putReference( id98, ref15 );
var id104 = charIDToTypeID( "T   " );
var desc22 = new ActionDescriptor();
var id105 = stringIDToTypeID( "performance" );
var id106 = stringIDToTypeID( "performance" );
var id107 = stringIDToTypeID( "stepByStep" );
desc22.putEnumerated( id105, id106, id107 );
var id108 = charIDToTypeID( "PbkO" );
desc21.putObject( id104, id108, desc22 );
executeAction( id97, desc21, DialogModes.NO );
}


Timo Autiokari
Mike Hale

cs2 force screen redraw

Post by Mike Hale »

I'm glad that you found something that works for you.

I ran your test script and I still see the image window refresh. I have tested it on 2 WinXP systems. Both have the playback options set to accelerated

Mike
Timo Autiokari

cs2 force screen redraw

Post by Timo Autiokari »

Hi Mike, odd that it is working for you. At work I tested it on 5 computers that have XP and CS2 and they do not redraw. In 3 of them I was working with admin rights, on two other as powerUser. Here at work CS2 on a Win2000 computer does not redraw either.

Thank you,
Timo Autiokari