I've written a file exporter in javascript for Photoshop which displays a dialog and allows the user to select some options then exports to multiple files. I'd like to provide a button in the dialog which creates an Action, and assigns a Function key shortcut to run the script afterwards by hitting the Function key.
Usually, the user would create the Action manually, but most of my users aren't familiar with Actions and I'd like to make the workflow as simple as possible.
So. I've used the ScriptingListener.plugin to grab the actions that are played when I manually create the Action (from the actions panel; create an action, name it, choose a function key, hit 'record', browse to my script, run it, end recording) and this is what it records;
var id1 = stringIDToTypeID( "AdobeScriptAutomation Scripts" );
var desc1 = new ActionDescriptor();
var id2 = charIDToTypeID( "jsCt" );
desc1.putPath( id2, new File( "/Users/stewart/Projects/Export.jsx" ) );
var id3 = charIDToTypeID( "jsMs" );
desc1.putString( id3, "undefined" );
executeAction( id1, desc1, DialogModes.YES );
This appears to be just the code to run the script, but not the code to create the action.
My assumption at this point is that because the ScriptingListener doesn't capture these interactions, scripting this won't be possible.开发者_运维技巧
I'm working with Photoshop CS3 or later.
Is it possible to write a script which creates an Action that will run the script (effectively installing an Action for itself)?
Further, can the script also assign a shortcut key for the created Action?
Ok. You already have some script. But you need it to create an action, which will execute this script and assign a hotkey for it? Seemed to be an overkill.
I may advice you create an Action manullay and then assign a hotkey for each computer. Also, if all computers are in the same network, you may share your script in public directory from you machine and execute script from network path. Thus, you'll not need to update it manually every time on each computer, where it's used.
精彩评论