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)

Vol46Author
Participant
December 5, 2021

Have you installed the Scriptlisener to see what the VBS action manager code it logs when you add, remove, clear, move guide lines?  Adobe Photoshop JavaScript support do not cover all of Photoshop features either.  Often to script some Photoshop function in a Photoshop Javascript one need to use Action Manager code.  Adobe's Scriptlisener Plug-in records/log/ Steps like the Action Palettes Action recorder what you do in Photoshop ir recirder int action steps. The  Scriptlisener Plug-in records two logs  in one Action Steps are log ins VBS code and  in the other log the Action Step are recorded in JavaScript Code.   Like  Action have hard coded step setting.    The Action manager code can be use in Photoshop script  JaveScript and VBS Scripts there is no support for AppleScript.  The Action Manager code can be use to use Photoshop Features not covered by  Adobe's JavaScript and VBS Script support. So  in VBS  you have two Options you can use either the  Action Manger code logs.  The VBS version the javasctipt version.  In either code you can replace the hare coded step settings with variables.  Create Step functions you can pass parameters to for the step's settings values.


JJMack, thank You! I know about action manager and Scriptlisener and use it. But to get position existing guides - in Scriptlisener logs I not found a decisions. So, I done this with DoJavaScript.

Another solution is to set paths from one point to the right places and use their coordinates (and they are available from both VB and Python) instead of guides. It also work.

PS. when I don't need logs so that ScriptListener doesn't slow down photoshop, I rename its file.