Problem setting guides color with batchPlay

Using Alchemist and batchPlay I had no trouble GETTING the guides color, but I’m having a heck of a time SETTING it. I started with this:

async function setGuidesColor(color) {
	const result = await batchPlay(
				_obj: "set",
				_target: [
							_ref: "property",
							_property: "guidesPrefs"
							_ref: "application",
							_enum: "ordinal",
							_value: "targetEnum"
				to: {
					 _obj: "guidesPrefs",
					 guidesColor: {
							_enum: "guideGridColor",
							_value: "mediumBlue" //temporary for testing
				_options: {
					 dialogOptions: "dontDisplay"
		 synchronousExecution: false,
		 modalBehavior: "wait"

but it crashed, so with my suspicions aroused I moved the batchPlay code into a function called setGuidesColorModal and did this:

async function setGuidesColor(color) {
		try {
			await require('photoshop').core.executeAsModal(setGuidesColorModal, 
				{"commandName": "Setting guides color",
					descriptor: {setColor: color} //not yet really using this during testing
		catch(e) {

but that threw “The command failed because Photoshop is in a modal state”. The only UI features open are PS’s main window, the UXP Developer Tool, and a non-modal panel for the plugin where I click a button that starts a fairly simple sequence of code to do the following:


I’m at my wits end. Any help will be appreciated.

PS: for

modalBehavior: "wait"

I experimented with “fail”, “wait”, and “execute”. For “execute” it locked up and showed the eternal progress bar, for “fail” it threw the aforementioned exception, and for “execute” it succeeded in setting the guides color, but crashed when exiting the setGuidesColorModal function.

1 Like


I don’t know if it will be helpfull, but I did this and it work fine in my plugin :

const app = require('photoshop').app;
const constants = require('photoshop').constants;

require('photoshop').core.executeAsModal(async () => {
    let w = app.activeDocument.height / 2;
    let r = 255, g = 0, b = 0;
    let orientation = constants.Direction.HORIZONTAL;

    await require("photoshop").action.batchPlay([{
        "_obj": "make",
        "guideTarget": {
            "_enum": "guideTarget",
            "_value": "guideTargetCanvas"
        "new": {
            "$GdCA": 0,
            "$GdCB": b,
            "$GdCG": g,
            "$GdCR": r,
            "_obj": "good",
            "orientation": {
                "_enum": orientation,
                "_value": orientation
            "position": {
                "_unit": "pixelsUnit",
                "_value": w
},{"commandName": "Guide"});

With that, I can change orientation / position / color of the guide I want to create.