haller
1
Every time I use alchemist the code it creates doesn’t work, maybe I’m doing something wrong,
anyway:
here I generated a code with alchemist that selects the “Test” level but when I go to use it it doesn’t work,
where is the error?
const batchPlay = require('photoshop').action.batchPlay,
app = require('photoshop').app,
uxp = require('uxp'),
fs = require('fs'),
fslocal = require('uxp').storage.localFileSystem,
exeModal = require('photoshop').core.executeAsModal,
core = require('photoshop').core,
showAlert = require('photoshop').core.showAlert,
entrypoints = require('uxp').entrypoints,
shell = require('uxp').shell
document.getElementById("btnTest").addEventListener("click", test1);
async function test1() {
const batchPlay = require("photoshop").action.batchPlay;
const result = await batchPlay(
[
{
_obj: "select",
_target: [
{
_ref: "layer",
_name: "Test"
}
],
makeVisible: false,
layerID: [
6
],
_options: {
dialogOptions: "dontDisplay"
}
}
],{
synchronousExecution: false,
modalBehavior: "fail"
});
}
Maher
2
just to be sure, are you using execute as modal?
haller
3
no I’m not using as modal
for example if I put an alert it works
If I take it off it doesn’t work?
document.getElementById("btnTest").addEventListener("click", test1);
async function test1() {
alert("ok")
const batchPlay = require("photoshop").action.batchPlay;
const result = await batchPlay(
[
{
_obj: "select",
_target: [
{
_ref: "layer",
_name: "Test"
}
],
makeVisible: false,
layerID: [
6
],
_options: {
dialogOptions: "dontDisplay"
}
}
],{
synchronousExecution: false,
modalBehavior: "fail"
});
}
haller
4
Maher Thank you
you made me think and I managed to make it work, I don’t know if it’s the best way to do it but it works for me.
here’s the script.
document.querySelector('#btnTest').addEventListener('click', () => {
TestRun()
})
async function Test() {
const batchPlay = require("photoshop").action.batchPlay;
const result = await batchPlay(
[
{
_obj: "select",
_target: [
{
_ref: "layer",
_name: "Test"
}
],
makeVisible: false,
layerID: [
6
],
_options: {
dialogOptions: "dontDisplay"
}
}
],{
synchronousExecution: false,
modalBehavior: 'execute',
});
}
async function TestRun() {
await require('photoshop').core.executeAsModal(Test, {
commandName: 'Action Commands',
})
}
1 Like