Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

ExtendScript: how to get screens size?

Contributor ,
Dec 27, 2024 Dec 27, 2024

Copy link to clipboard

Copied

Hello,

 

I'm trying to get working an old jsx script + applescript that split my main screen with the two frontmost Photoshop documents - it was very useful for comparing two documents.
This script worked with an old Photoshop CS6 but it gives an error on Photoshop 2025 when I try to retrieve my screen sizes.
I was using :

app.getCustomOptions('screensSize').getString(0)

Do you know any Photoshop 2025 compatible equivalent?

TOPICS
Actions and scripting , macOS

Views

514
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Dec 28, 2024 Dec 28, 2024
quote

Sorry, I forgot to answer your question. This is a part of my script and the results.

 

	var myProp = 'screensSize';
	var myString = 'Hello';
	var desc = new ActionDescriptor();
	app.putCustomOptions(myProp, desc, false);
	
	alert(app.getCustomOptions('screensSize')); // --> [ActionDescriptor] : [count]'0' [typename]'ActionDescriptor'
	alert(app.getCustomOptions('screensSize').getString(0)); // --> ERROR 8500 : property doesn't exist

 

I'll try with your links.


By @frmorel

First, you use getString(),

...

Votes

Translate
Engaged ,
Dec 27, 2024 Dec 27, 2024

Copy link to clipboard

Copied

If I understand correctly, do you need this?

Schermata 2024-12-27 alle 18.52.11.pngexpand image

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 27, 2024 Dec 27, 2024

Copy link to clipboard

Copied

Thank you for your answer.

 

Yes, this kind of display.
But better:
- I would like only the windows of the two frontmost documents to be modified
- I would also like the windows of any other documents not to be placed in tabs

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 28, 2024 Dec 28, 2024

Copy link to clipboard

Copied

you could put a screenshot of what you would like. 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 28, 2024 Dec 28, 2024

Copy link to clipboard

Copied

its nice I like that script.. but I don't know the compatible thing.

 

Online gamer

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2024 Dec 28, 2024

Copy link to clipboard

Copied

Did you »app.putCustomOptions(…« before trying to get them? 

Otherwise there being nothing to retrieve seems logical. 

 

Please post screenshots illustrating what you mean exactly. 

If you (understandably for a Mac-user) don’t want tabs please disable them via the Preferences (»Open Documents as Tabs« and QEnable Floating Document Window Docking«). 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 28, 2024 Dec 28, 2024

Copy link to clipboard

Copied

app.getCustomOptions('screensSize')

returns "error 1302" -> Nonexistent element

These are some screen captures:

 

1 - initial demo state (please note the order of the windows : car and cat are the two frontmost documents)

 

01.jpgexpand image

 

 

2 - what I want (what I had in CC6!) - dog document has not been affected, it is below the others

 

02.jpgexpand image

 

 

3 - what I have with Arrange > 2-up Vertical - note the tab (though open docs in tabs is not checked in the settings)

 

03.jpgexpand image

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2024 Dec 28, 2024

Copy link to clipboard

Copied

quote

3 - what I have with Arrange > 2-up Vertical - note the tab (though open docs in tabs is not checked in the settings)

But is »Enable Floating Document Window Docking« checked? 

Edit: Never mind, apparently the Preferences settings are disregarded when invoking those arrangements. 

 

Again: Did you putCustomOptions

If not what would be there to retrieve? 

I suspect you set this up when installing the Script/s originally on CS6 and you would have to do the same for 2025. 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2024 Dec 28, 2024

Copy link to clipboard

Copied

I generally use txt-files to store data across runs of a Script but in this thread 

https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-record-javascript-dialog-input...

I posted an example @Paul Riggott had originally posted (though I may have changed the code somewhat, I cannot locate the original thread) that shows how to use getCustomOptions and putCustomOptions to store and retrieve information. 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 28, 2024 Dec 28, 2024

Copy link to clipboard

Copied

Sorry, I forgot to answer your question. This is a part of my script and the results.

	var myProp = 'screensSize';
	var myString = 'Hello';
	var desc = new ActionDescriptor();
	app.putCustomOptions(myProp, desc, false);
	
	alert(app.getCustomOptions('screensSize')); // --> [ActionDescriptor] : [count]'0' [typename]'ActionDescriptor'
	alert(app.getCustomOptions('screensSize').getString(0)); // --> ERROR 8500 : property doesn't exist

I'll try with your links.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2024 Dec 28, 2024

Copy link to clipboard

Copied

Forgive the bluntness, but that code seems contradictory to me.

You define »desc« as a new ActionDescriptor, put it in custom options with the name »myProp«, then

• try to retrieve it by the name »screensize« and

• expect it to carry some specific information. 

 

But … I seem to vaguely recall that custom options cannot be defined by simple names anymore but need to be identified by a UUID – a change that was implemented some time after CS6, I expect.  

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 28, 2024 Dec 28, 2024

Copy link to clipboard

Copied

You're right, there is a small mistake in my demo code.

But if I write :

app.putCustomOptions('screensSize', desc, false);

I have the same error. Maybe it's due to the UUID identifier... but what is an UUID? Where could I find some detailed informations about app.putCustomOptions()?

Anyhow, if it's too complicated, I think I can make a workaround for my problem with an Applescript.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 29, 2024 Dec 29, 2024

Copy link to clipboard

Copied

quote

but what is an UUID?


By frmorel

 

You can Goolge or ask AI about  UUID or GUID.

 

For Photoshop, they are most “commonly” used in scripts to provide a unique I.D. for a custom menu item, such as the <eventid></eventid> used in the <javascriptresource></javascriptresource> block in scripts such as Export Layers to Files. I have also used them when adding a layer that should have a "unique" name.

 

Here are a couple of script examples:

alert(generateGuid());

function generateGuid() {
  // GUID generator
  /* http://blog.shkedy.com/2007/01/createing-guids-with-client-side.html */
  /* https://en.wikipedia.org/wiki/Universally_unique_identifier */
  var result, i, j;
  result = '';
  for (j = 0; j < 32; j++) {
    if (j == 8 || j == 12 || j == 16 || j == 20)
      result = result + '-';
    i = Math.floor(Math.random() * 16).toString(16).toUpperCase();
    result = result + i;
  }
  return result;
}

 

Or:

 

alert(uuid());

function uuid() {
  /* https://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid */
  var chars = '0123456789abcdef'.split('');

  var uuid = [],
    rnd = Math.random,
    r;
  uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
  uuid[14] = '4'; // version 4

  for (var i = 0; i < 36; i++) {
    if (!uuid[i]) {
      r = 0 | rnd() * 16;

      uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r & 0xf];
    }
  }

  return uuid.join('');
}

 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 29, 2024 Dec 29, 2024

Copy link to clipboard

Copied

LATEST

Thank you Stephen for your explanations.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Dec 28, 2024 Dec 28, 2024

Copy link to clipboard

Copied

quote

Sorry, I forgot to answer your question. This is a part of my script and the results.

 

	var myProp = 'screensSize';
	var myString = 'Hello';
	var desc = new ActionDescriptor();
	app.putCustomOptions(myProp, desc, false);
	
	alert(app.getCustomOptions('screensSize')); // --> [ActionDescriptor] : [count]'0' [typename]'ActionDescriptor'
	alert(app.getCustomOptions('screensSize').getString(0)); // --> ERROR 8500 : property doesn't exist

 

I'll try with your links.


By @frmorel

First, you use getString(), but I don't see putString().

Second, don't use 0 for the key(id) argument.   more 

 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 28, 2024 Dec 28, 2024

Copy link to clipboard

Copied

It works! Thank you very much for your help.

 

	var myProp = 'screensSize';
	var myString = 'Hello';
	
	var desc = new ActionDescriptor();
	desc.putString(1, myString); 
	app.putCustomOptions(myProp, desc, false);

	alert(app.getCustomOptions(myProp).getString(1)); // --> "Hello"

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 29, 2024 Dec 29, 2024

Copy link to clipboard

Copied

I apologize, I was mistaken, the UUID-identification is apparently not necessary. 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines