How can I set the clone stamp offset from UXP / batchPlay assuming Aligned is checked?

How can I set the X/Y offset for clone stamp as seen in the Window → Clone Source dialog?

I have written a UXP plugin to let me select two points in the image and figure out the optional clone stamp pixel offset so that the halftone dots line up perfectly, since this is a real pain in the tuckus to do in Photoshop - if you’re off by a single pixel it is extremely visible, so you gotta zoom in and hover and squint.

I have gotten most of it working already! I have the user hit a button which activates the color selector, they choose source and destination point, hit another button, then I read the coordinates, grab the pixels around them, convolve them at different offsets to see which has maximum alignment, spit out the optimal offset and even set the cloneSource point no problem.

But… I can’t for the life of me figure out how to actually set the Aligned Offset (as seen in the WIndow → Clone Source window), and without that this is all useless. Alchemist plugin Listener shows an event for choosing the Clone Stamp source, so I knew how to that. However, the next click with the clone stamp tool, which should set the initial alignment, shows nothing in Alchemist Listener except toolModalStateChange enter and exit so I have no idea what to write in my batchPlay “set”.

Anyone know? Or know why no paint events at all (even brush) are showing up an event in Alchemist listener? Maybe paint events aren’t exposed or maybe I just don’t have something turned on? I do have Actions → Allow Tool Recording on.

Thanks!

FWIW, here’s the code I use to set the clone stamp source, works great. I have since flailed around trying different things for the offset like “cloneOffset”, “cloneDest”, “cloneDestination”, etc. to no avail. Even “cloneSource” isn’t documented anywhere that I could find.

        await batchPlay( [
            {
                _obj    : "set",
                _target : [
                    { _ref : "property", _property : "cloneSource" },
                    { _ref : "application", _enum : "ordinal", _value : "targetEnum" }
                ],
                to      : {
                    _obj     : "imageCachePreferences",
                    source   : {
                        _ref   : "layer",
                        _enum  : "ordinal",
                        _value : "targetEnum"
                    },
                    position : {
                        _obj       : "point",
                        horizontal : { _unit : "pixelsUnit", _value : sourceX },
                        vertical   : { _unit : "pixelsUnit", _value : sourceY }
                    }
                },
                _options : {
                    dialogOptions : "dontDisplay"
                }
            }
        ], { synchronousExecution : false } );

Okay, I’ve found requests for this going back over a decade, but nothing. Apparently, somehow, nobody has ever needed this functionality in 40 years. Guess because Photoshop is more aimed at, well, photos than comics?

So I’ve used AutoHotKey v2 to cobble up a ‘working’ solution where the plugin puts the values on the clipboard, then AHK script picks them up and stuffs them into the Clone Source window. Hacks on Hacks, but it works and is certainly better than doing it by hand. Still interested in hearing if anyone ever comes up with the real answer, though! Then I could actually release this for other people to use.