Skip to main content
Naoki-Hada
Known Participant
August 21, 2018
Answered

[Q] "Reset Default Workspaces" by scripting?

  • August 21, 2018
  • 2 replies
  • 1168 views

Hi all,

Is there way to do "Reset Default Workspaces" by scripting (or progmatically)?

First preference is by ExtendScript.

Alternatively, out side of Photoshop app. Ex) delete file or edit registry.

Purpose is for preparing before and clean up after automated unit test.

My understanding is there is 2 way to do on UI.

1) Menu: Edit -> Preferences -> Workspace -> Restore Default Workspaces

2) Menu: Window -> Workspace -> Reset Essentials (Default)

Thank you,

Naoki

Correct answer Kukurykus

function sTT(v) {return stringIDToTypeID(v)}

(ref = new ActionReference()).putName

(sTT('workspace'), 'Essentials');

(dsc = new ActionDescriptor())

.putReference(sTT('null'), ref)

executeAction(sTT('reset'), dsc)

2 replies

Naoki-Hada
Known Participant
August 21, 2018

Kukurykus

Thank you very much for the code.

It works perfectly.

One thing I missed in the question was I needed to select 'Essentials' workspace before reset.

Following code was added selection code for someone's help.

function sTT(v) {

    return stringIDToTypeID(v)

}

(ref = new ActionReference()).putName (sTT('workspace'), 'Essentials');

(dsc = new ActionDescriptor()).putReference(sTT('null'), ref);

executeAction(sTT('select'), dsc);

executeAction(sTT('reset'), dsc);

Thank you very much,

Naoki

Kukurykus
Legend
August 21, 2018

I actually predicted that you can meet problem when this workspace is not chosen but it seems you were smart to find it Remember also when it is chosen and you reset it, it is not completetly same workspace as it does not choose "Move Tool".

function sTT(v) {return stringIDToTypeID(v)}

(ref = new ActionReference()).putName

(sTT('workspace'), 'Essentials');

(dsc = new ActionDescriptor())

.putReference(sTT('null'), ref)

executeAction(sTT('select'), dsc)

Kukurykus
KukurykusCorrect answer
Legend
August 21, 2018

function sTT(v) {return stringIDToTypeID(v)}

(ref = new ActionReference()).putName

(sTT('workspace'), 'Essentials');

(dsc = new ActionDescriptor())

.putReference(sTT('null'), ref)

executeAction(sTT('reset'), dsc)