Salir
  • Comunidad global
    • Idioma:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

ExtendScript: how to get screens size?

Colaborador ,
Dec 27, 2024 Dec 27, 2024

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?

TEMAS
Acciones y scripts , macOS
1.2K
Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines

correct answers 1 respuesta correcta

Campeón , 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(),

...
Traducir
Adobe
Aficionado ,
Dec 27, 2024 Dec 27, 2024

If I understand correctly, do you need this?

Schermata 2024-12-27 alle 18.52.11.png

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Colaborador ,
Dec 27, 2024 Dec 27, 2024

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

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Aficionado ,
Dec 28, 2024 Dec 28, 2024

you could put a screenshot of what you would like. 

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Nuevo aquí ,
Dec 28, 2024 Dec 28, 2024

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

 

Online gamer

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Community Expert ,
Dec 28, 2024 Dec 28, 2024

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«). 

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Colaborador ,
Dec 28, 2024 Dec 28, 2024
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.jpg

 

 

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

 

02.jpg

 

 

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

 

03.jpg

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Community Expert ,
Dec 28, 2024 Dec 28, 2024
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. 

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Community Expert ,
Dec 28, 2024 Dec 28, 2024

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. 

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Colaborador ,
Dec 28, 2024 Dec 28, 2024

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.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Community Expert ,
Dec 28, 2024 Dec 28, 2024

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.  

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Colaborador ,
Dec 28, 2024 Dec 28, 2024

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.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Community Expert ,
Dec 29, 2024 Dec 29, 2024
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('');
}

 

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Colaborador ,
Dec 29, 2024 Dec 29, 2024
MÁS RECIENTES

Thank you Stephen for your explanations.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Campeón ,
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(), but I don't see putString().

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

 

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Colaborador ,
Dec 28, 2024 Dec 28, 2024

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"
Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Community Expert ,
Dec 29, 2024 Dec 29, 2024

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

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines