Skip to main content
Participant
December 4, 2021
Answered

Where sone properties in Photoshop VBScripting?

  • December 4, 2021
  • 1 reply
  • 767 views

Where Document.guides property in Photoshop VBScripting? How to get positions of guides?

Where ArtLayer.findByName() method in Photoshop VBDcripting?

This topic has been closed for replies.
Correct answer Vol46

I found solve...

Application.DoJavaScript and DoJavaScriptFile gives my possibility to get guides property.

Thank to all!

1 reply

JJMack
Community Expert
Community Expert
December 4, 2021

If you can not find a Method in Photoshop VBS Reference you may need to use Action manager code or JavaScript code.  I do not know anything about VBS code or Adobe support for VBS code.

In Photoshop javascripts I actually use Action manger code sometimes.  Functions I made from scriptlisner code. Scriptlistener also log vbs code on your deaktop. However I set the log file's Attribute to Read Only. So it will not grow and need to cleared out so it will not fill up my SSD.

 

Here the javascript Action manager code I use.  I do not know what VBS action manager code looks like.  If it like the javascript code it will not be very readable

/////////////////////////////////////////////////////
function MarkX(x) {
// =======================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc61 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
        var desc62 = new ActionDescriptor();
        var idPstn = charIDToTypeID( "Pstn" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc62.putUnitDouble( idPstn, idPxl, x);
        var idOrnt = charIDToTypeID( "Ornt" );
        var idOrnt = charIDToTypeID( "Ornt" );
        var idVrtc = charIDToTypeID( "Vrtc" );
        desc62.putEnumerated( idOrnt, idOrnt, idVrtc );
    var idGd = charIDToTypeID( "Gd  " );
    desc61.putObject( idNw, idGd, desc62 );
executeAction( idMk, desc61, DialogModes.NO );
}
function MarkY(y) {
// =======================================================
var idMk = charIDToTypeID( "Mk  " );
    var desc63 = new ActionDescriptor();
    var idNw = charIDToTypeID( "Nw  " );
        var desc64 = new ActionDescriptor();
        var idPstn = charIDToTypeID( "Pstn" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc64.putUnitDouble( idPstn, idPxl, y );
        var idOrnt = charIDToTypeID( "Ornt" );
        var idOrnt = charIDToTypeID( "Ornt" );
        var idHrzn = charIDToTypeID( "Hrzn" );
        desc64.putEnumerated( idOrnt, idOrnt, idHrzn );
    var idGd = charIDToTypeID( "Gd  " );
    desc63.putObject( idNw, idGd, desc64 );
executeAction( idMk, desc63, DialogModes.NO );
}

 

 

JJMack
Vol46Author
Participant
December 4, 2021

JJMack, thank You for respond!

I know this Javascript possibility. I use python scripting and my equivalent code is:

 

 

import comtypes.client as cli
import psCharID
dialogMode = psDisplayNoDialogs

def guideLine2(app, position, type):
    descData = cli.CreateObject( "Photoshop.ActionDescriptor" )
    descData.putEnumerated( psCharID.ps_Ornt, psCharID.ps_Ornt, type );
    descData.putUnitDouble( psCharID.ps_Pstn, psCharID.ps__Pxl, position );
    descGuide = cli.CreateObject( "Photoshop.ActionDescriptor" )
    descGuide.putObject( psCharID.ps_Nw, psCharID.ps_Gd, descData );
    app.executeAction(psCharID.ps_Mk, descGuide, dialogMode)

psApp = cli.CreateObject('Photoshop.Application')
doc = psApp.activeDocument
guideLine2(psApp, 500, psCharID.ps_Vrtc)

 

 

As Adobe write: "Photoshop supports external automation through scripting. In Windows, you can use scripting languages that support COM automation, such as VB Script. In Mac OS, you can use languages such as AppleScript that allow you to send Apple events. These languages are not cross-platform but can control multiple applications such as Adobe Photoshop, Adobe Illustrator, and Microsoft Office. In Mac OS, you can also use Apple’s Photoshop Actions for Automator to control tasks in Photoshop.

You can also use JavaScript on either platform. JavaScript support lets you write Photoshop scripts that run on either Windows or Mac OS."

I need to get coordinates for existing guides in document (by script). JavaScript give this possibility and Document.guides property exists (https://github.com/Adobe-CEP/CEP-Resources/blob/master/Documentation/Product%20specific%20Documentation/Photoshop%20Scripting/photoshop-javascript-ref-2020.pdf) In VBScripting that property absent (why???). (And external automation through python use VBScript model)

Vol46AuthorCorrect answer
Participant
December 4, 2021

I found solve...

Application.DoJavaScript and DoJavaScriptFile gives my possibility to get guides property.

Thank to all!