Copy link to clipboard
Copied
Hello,
I am getting the message...
"Could not complete the command because Photoshop was unable to find the JavaScript file."
This happens when I try to run a script that will detect if the active document is Landscape or Portrait.
The script works just fine when used manually, and even when I record it into an action. But when the
action is tested it gives this error message.
I have called adobe but they said it's a script issue so they cannot help me.
I have many other actions using the exact same script that work just fine so I have no idea
what is wrong.
I recently added the #target photoshop part at the front of the script
and that seemed to work for awhile but now even that is not helping it.
Any help is greatly appreciated, here is the script....
#target photoshop
var doc = app.activeDocument;
if(doc.width.value>doc.height.value){//Landscape
doAction("AddHorBack", "Automations");
}else{//Portrait
doAction("AddPortBack", "Automations");
}
Copy link to clipboard
Copied
Please post a screen capture that shows Photoshop UI with the Error message. Also post the two Automations Actions AddHorBlack and AddPortBlack where the actions are fully expanded so can see if these actions have scripts steps. The script you posted will play one of these two actions. That script is basically a one line if else statement and does not include other scripts. The Actions may. That script also will not work correctly if Photoshop's ruler units is set to percentage for width and height will always be equal to 100% no matter what orientation the document has. It will always play AddPortBlack.....
Copy link to clipboard
Copied
Hi JJMack,
Thanks for responding!
Here is what you requested. The two actions do have another script in them but
they both work fine when ran manually.
The hangup comes when running "Step 3 Same Back"
The Place happens fine, and then the "Scripts" is what throws up the error message.
Also, the rulers are set to inches so that is fine, good idea to check that!
Let me know if you need any other info.
THANK YOU!!!!
Copy link to clipboard
Copied
You did not post Photoshop screen capture showing Photoshop UI with the error message showing so I could see which action was failing and in which step. You also did not post the two actions fully expanded so I could see the setting and script names the actions uses.
You posted just the error popup and the action showing steps but no step information. If an other action "Step 3 Same Black" Place in a file and uses a script we would need to see the the script name is and the contents of that script the seems to be the step that the "Step 3 Same Black" action has highlighted which may be the script step that is not being found.
Use the ALT Key when you expand the action so you can read what steps do.
Copy link to clipboard
Copied
Hi JJMack,
Sorry...Is this better?
Here is the full screenshot of the error and the part of the action that is failing.
And the other two actions are shown again, I don't know how to expand them further
but I just took the scripts out of those anyway to simplify this a little bit.
I double checked all the file names, script names, and action names. Everything looks fine.
Also included is a screen shot of the script.
Thanks again!
- Jim
Copy link to clipboard
Copied
You could add some error checking....
#target photoshop;
app.bringToFront();
main();
function main(){
if(!documents.length) return;
try{
var doc = app.activeDocument;
app.displayDialogs = DialogModes.NO;
var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
if(doc.width.value > doc.height.value){
doAction("AddHorBack","Automations");
}else{
doAction("AddPortBack","Automations");
}
}catch(e){alert(e + "\nError on line " + e.line);}
finally{
app.preferences.rulerUnits = strtRulerUnits;
app.preferences.typeUnits = strtTypeUnits;
}
};
Copy link to clipboard
Copied
That fixes the ruler unit problem but I fail to see how it would help solve any problem in the Actions and scripts that the actions may use.
Copy link to clipboard
Copied
If that fails a reset of the preferences might be in order.
Copy link to clipboard
Copied
I don't know if that will help but you can:
- copy your script to 'Presets / Scripts' folder of your Photoshop
- after you relaunch Ps, expand your action, remove current script
- open dropdown action menu and choose 'Select Menu Item'
- click 'File / Scripts' and select the name of script
I remember I had some similar problem, and maybe that was a way how I solved it. So it's worth to just try.
The difference is, now when you look at your script name from action you see not script path, but its name.
Copy link to clipboard
Copied
Thanks Kukurykus! And everyone else!
I just moved the script to the Preset/Scripts folder and
ran it from there. All my other scripts are NOT in this folder
so I don't see why that makes a difference but it did work!
I have tried this before without success so I don't feel like
this is the permanent answer. But I am glad this is working again!!!
****************************************************************************************************
- open dropdown action menu and choose 'Select Menu Item'
- click 'File / Scripts' and select the name of script
Kukurykus... When I try to record an action/script using "Insert Menu Item"
It only allows me to choose from a long list of my scripts but the script
I want is not there. I don't know how to reset that list. The only option
is to browse for the script but that is not an option in record mode.
Am I missing something???
****************************************************************************************************
Copy link to clipboard
Copied
In that long list you will see only scrpits that before launching Photoshop were copied to mentioned 'Presets / Scripts' folder.
Copy link to clipboard
Copied
I keep all the Scripts I add to Photoshop in my own Scripts File system tree. In all version of Photoshop I have installed I add a link to my script tree into their \Presets\Script\ folder. That way all Photoshop versions use the same script files and there is only one copy I need to maintain. Installing a new version of Photoshop only requite me to add the link into the new Photoshop versions \Presets\scripts\...
Copy link to clipboard
Copied
Thanks, that seems like a great idea! Can you show what you mean by
"In all version of Photoshop I have installed I add a link to my script tree into their \Presets\Script\ folder."
I don't understand that part.
Thanks!
Copy link to clipboard
Copied
If you're on Windows, go to the folder where is the folder with your scripts. Then right mouse click on and make a shortcut (you can sent it to Desktop). Then copy it to 'Presets' folder of your Photoshop(s). Now any time you launch any Photoshop you have installed where each got that 'shortcut' in its 'Presets' folder you will see loaded in scripts listed in 'File / Scripts'
Copy link to clipboard
Copied
A Windows Shortcut is a link so I have windows create a Shortcut(link) to my Photoshop scripts tree C:\Photoshop Scripts\ onto my desktop. I copy that file into Photoshop versions Presets\Scripts\ Folder you can see my tree here how many files I add and the link in CC 2019 presets\scripts\ folder I also move folders in and out of me tree. When I do I need to restart Photoshop. For Photoshop builds its menu File>Scripts\Script Names Item list when you start Photoshop. You actually do not want to add 196 scripts to Photoshop Scripts Name list for Adobe Photoshop only scrolls the list a single item at a time. It hard to navigate a long list. I may use Windows File explorer instead of menu File>Scripts>Script Name. In windows files explorer you can search for the script name and then drag the script onto Photoshop and drop it to run the script. I also use the Free Photoshop Extension JSXluncher to have a second Script list I want quick access to or for scripts I'm working on and am testing. JSXlaunched Script List can be changed while Photoshop is UP.
]
Copy link to clipboard
Copied
Hey JJMack
How do you add the separators? Are they folders dividers? I dont seem to have them on MAC?
Copy link to clipboard
Copied
They are Category group deviders. You created groups of scripts in your script's code. In a HARVEST EXCEPTION ZSTRING section. For example script in my Photo Collage Tool kit a I created a group category "JJMack's Collage Scrtpt" their HARVEST EXCEPTION ZSTRING section look something like this
/* Help Category note tag menu can be used to place script in automate menu
<javascriptresource>
<about>$$$/JavaScripts/BatchMultiImageCollage/About=JJMack's Batch populate a multi Image Collage.^r^rCopyright 2010 Mouseprints.^r^rBatch populate a multi Image collage template</about>
<category>JJMack's Collage Script</category>
</javascriptresource>
*/
My Plug-ins are in the Automate menu my my category JJMack's
// BEGIN__HARVEST_EXCEPTION_ZSTRING
<javascriptresource>
<name>$$$/JavaScripts/AspectRatioSelection/Name=Aspect Ratio Selection...</name>
<about>$$$/JavaScripts/AspectRatioSelection/About=Aspect Ratio Selection Plug-in Version 0.0 By JJmack a Hacker use at your own risk Quality forget about it.</about>
<menu>automate</menu>
<category>JJMack's</category>
<enableinfo>true</enableinfo>
<eventid>3caa3434-cb67-11d1-bc43-0060b0a13dc5</eventid>
<terminology><![CDATA[<< /Version 1
/Events <<
/3caa3434-cb67-11d1-bc43-0060b0a13dc5 [($$$/AdobePlugin/AspectRatioSelection/Name=Aspect Ratio Selection) /imageReference <<
/width [($$$/AdobePlugin/AspectRatioSelection/Width=width) /pixelsUnit]
/height [($$$/AdobePlugin/AspectRatioSelection/Height=height) /pixelsUnit]
/flagCENTER [($$$/AdobePlugin/AspectRatioSelection/Center=center) /boolean]
/flagBORDER [($$$/AdobePlugin/AspectRatioSelection/Border=border) /boolean]
/flagRECTANGLE [($$$/AdobePlugin/AspectRatioSelection/Rectangle=rectangle) /boolean]
/flagELLIPSE [($$$/AdobePlugin/AspectRatioSelection/Ellipse=ellipse) /boolean]
/flagREPLACE [($$$/AdobePlugin/AspectRatioSelection/Replace=replace) /boolean]
/flagADD [($$$/AdobePlugin/AspectRatioSelection/add=add) /boolean]
/flagSUBTRACT [($$$/AdobePlugin/AspectRatioSelection/Subtract=subtract) /boolean]
/flagINTERSECT [($$$/AdobePlugin/AspectRatioSelection/Intersect=intersect) /boolean]
/flagSLT [($$$/AdobePlugin/AspectRatioSelection/Selection=selection) /boolean]
/flagPTH [($$$/AdobePlugin/AspectRatioSelection/Path=path) /boolean]
/feather [($$$/AdobePlugin/AspectRatioSelection/Feather=feather) /pixelsUnit]
/flagANTIALIAS [($$$/AdobePlugin/AspectRatioSelection/anti-alias=anti-alias) /boolean]
>>]
>>
>> ]]></terminology>
</javascriptresource>
// END__HARVEST_EXCEPTION_ZSTRING
Copy link to clipboard
Copied
If that script file is there post it so I can see it includes other scripts
Copy link to clipboard
Copied
I just got the same thing trying to record my first script in PS 23.3.1 under Win 10. Wherever I put my simple script (that works fine during recording), it is "not found back" when playing... 😞
I tried placing it in all recommended spots and more — nothing works.
I'm newish to Win 10 and I suspect it's involved somehow, especially its folder protection systems. I'm gonna try to disable those.
In fact, coming from Win 7, I was suspecting I had to re-record my many actions calling scripts, as PS or Win 10 might not allow them to be in a folder on drive C. Funnily enough, all my actions calling these "old" scripts on c:\PS scripts DO work, yet when I record a new one nothing works (so far)...
Copy link to clipboard
Copied
You can't record a script, but you can record an action. We need a LOT more information, as in show the action you recorded with all steps to start with. Are your scripts in the correct folder?
Copy link to clipboard
Copied
To be more clear: I'm new to Win 10, not to PS Scripting. You can record a script into an action.
It's working now. I had to add a shortcut to my c:\PS scripts folder in Presets\Scripts so the scripts show up in PS. If I select it from that list during recording, PS will find it back.
Before it also worked when the script was browsed for. Its sucks that I have to make a new "active scripts" folder that doesn't have every possible script in it, but anyway...
Copy link to clipboard
Copied
BTW, it still doesn't explain why my "old" actions with scripts steps DID work... Why can it find those back on c:\PS scripts, and not if I put new ones there...?
Copy link to clipboard
Copied
C:\PS scripts is not a valid script folder that Adobe apps check at startup. That's the problem.
Copy link to clipboard
Copied
Then I guess adding the shortcut has made it valid. But again, it doesn't explain the above... My "old" actions with scripts did NOT need the shortcut to work. Works just like in Win 7.