It’s possible, yet a little complicated:
- Navigate Photoshop’s menu to match the plugin by name, then the panel by name.
- Read out the apps property
panelList
to check if the panel is currently visible - Programmatically open the panel by its menu command
To save you some time:
(remove types if you’re not using Typescript)
export const showPluginPanel = (pluginName: string, panelName: string, closeIfOpen: boolean = false) => {
const menuBar = getAppProperty('menuBarInfo')
const plugins = menuBar.submenu.find(item => item.menuID === 7200)
const plugin = plugins.submenu.find(item => item.title === pluginName)
const panel = plugin.submenu.find(item => item.title === panelName)
const panelState = getAppProperty('panelList').find(p => p.name === panelName)
if (!panelState.visible || panelState.obscured || closeIfOpen) {
performMenuCommand(panel.command)
}
}
export const appRef = { _ref: 'application', _enum: 'ordinal', _value: 'targetEnum' }
export function getAppProperty<T extends keyof ApplicationDescriptor>(prop: T): ApplicationDescriptor[T] {
return photoshop.action.batchPlay([
{
_obj: 'get',
_target: [{ _property: prop }, appRef],
},
], { synchronousExecution: true })[0][prop]
}
export function performMenuCommand(commandID: number) {
photoshop.core.performMenuCommand({
commandID
});
}