Skip to main content
Known Participant
December 7, 2009
Answered

Visited the house next door. Got kicked out when I offered a gift

  • December 7, 2009
  • 3 replies
  • 1135 views

I'm not the first and  I won't be the last.  I just got lured into it. Others have described this problem online in much less temperate language than I intend to use.

I am Applescripting away in InDesign, minding my own business, when it strikes me that I can simplify a rather tedious workflow involving images.

So I end up getting Photoshop to open an image I've got the lowdown on from InDesign. It's the first time I've opened the Photoshop Applescript dictionary and I am delighted to discover I can do all sorts of cool things. My script ends up prepping an image for editing in Photoshop.

Then I have the bright idea of writing a second script starting in Photoshop after the edit, doing the housekeeping, saving a copy of the image in a Hi Res images folder, closing the original without saving (it's a Jpeg workflow ) and getting the Finder to hide it in a Done folder, then returning to InDesign to re-link the image to the processed one in the High Res folder.

Finish writing it and then discover that to enter the kingdom of heaven that is Photoshop's Scripts folder, it has to be JavaScript. Applescript not

welcome.

I've nothing against JavaSceipt, except that I haven't learned it. In fact this has prompted me to download the demo of BBedit and some docs on the language.

It's just that hating to waste some hours of labour, I was wondering if my first JavaScript could be to launch my Applescript. Thus I could get into the Photoshop Scripts folder in disguise and assign a hotkey to it.

Is it possible I could do that with a JavaScript, or are there any other solutions... which don't require expenditure? I am doing this for a company that is tightening its belt so often that it squeaks when it speaks.

This topic has been closed for replies.
Correct answer Kasyan Servetsky

Any recommended  reading matter?

First of all, read Photoshop CS3 Scripting Guide.pdf (inside Adobe Photoshop CS3\Scripting Guide folder)

Check out these forums:

http://forums.adobe.com/community/photoshop/photoshop_scripting

http://www.ps-scripts.com/bb/

http://www.tranberry.com/photoshop/photoshop_scripting/index.html

Kasyan

3 replies

Kasyan Servetsky
Legend
December 8, 2009

I recommend you to check out this tool for javascripting in Photoshop: http://ps-scripts.sourceforge.net/xtools.html. You can record an action, or some code with ScriptingListener, and convert it to the script, to which you can make adjustments.

I know from my own experience that "mixed" scripts work well and are easy to write — at least I didn't have any problems with mixing JS and AS.

Kasyan

Known Participant
December 8, 2009

Thank you, Kasyan,

I think it would be rash of me to dive in "blind". Any recommended

reading matter?

Kasyan Servetsky
Kasyan ServetskyCorrect answer
Legend
December 8, 2009

Any recommended  reading matter?

First of all, read Photoshop CS3 Scripting Guide.pdf (inside Adobe Photoshop CS3\Scripting Guide folder)

Check out these forums:

http://forums.adobe.com/community/photoshop/photoshop_scripting

http://www.ps-scripts.com/bb/

http://www.tranberry.com/photoshop/photoshop_scripting/index.html

Kasyan

Inspiring
December 7, 2009

I know you said you no expenditure, but for something like $15, FastScripts will give you a much better scripts menu. It runs in all apps, is dynamic, context-sensitive, and lets you set keyboard shortcuts. IMO, PS's Scripts folder is a pretty poor effort.

Known Participant
December 8, 2009

Thanks, Shane, I have FastScripts on my laptop. It's version 2.31. I will probably have to fork out another fifteen bucks to get up to version 4, which I see is the current one. If it were just for me it would be the ideal solution, but there's no way I could persuade the company to get it for multiple machines. They have the USBs locked against pen drives, for goodness sake.

However, I have slept on the matter and am about to go all Mills and Boon (publishers of romantic fiction).

Did I say house next door? It's a luxuriously-appointed mansion in which I have spent many a joyous hour ... so long as I'm wearing my User hat.

But when I put on my Scripter hat and approach the servants' quarters, the normally genial butler, Jeeves, goes all red in the face, like a traffic light, and bars my way. I think he suspects me of harbouring dishonourable intentions towards Minnie, the charming chambermaid.

And I can't deny there's... electricity .... between us.  Love must have its way and I have a devious plan.

I could approach Jeeves and address him courteously in impeccable Javascript: "Good evening, Jeeves, set your foreground colour to green for a change!" then turn and call out to my ally, Indy, saying: "It's time to do my Applescript now!"

Since I have been using both the InDesign and Photoshop dictionaries in single Applescripts, surely it would be possible for a Javascript to do the same? I'm going to give it a try.

Will I get to marry Minnie and make lots of beautiful babies or will Jeeves produce a cosh and flatten me?

Any tips or snippets from experienced Javascripters for a total Javascript ignoramus will be gratefully received!

Inspiring
December 8, 2009

Calling js from AS in Photoshop is easy; it's going the other way that's the problem.

In fact, calling js is the only way to do certain things via AS in Photoshop. Fortunately you can use ScriptingListener,plugin to write the js for you.

Jongware
Community Expert
Community Expert
December 7, 2009

For InDesign, we have app.doScript  (script: {File | String | JavaScript Function} [, language: ScriptLanguage=ScriptLanguage.UNKNOWN][, withArguments: Array of any][,undoMode: UndoModes=UndoModes.SCRIPT_REQUEST][, undoName: string=Script])

-- and in that long list of parameters, we find .. ScriptLanguage! An exclamation point is warranted, as one of these is ScriptLanguage.APPLESCRIPT_LANGUAGE !!

... At this point, I suggest you google around for doScript. Ne'er used it (well ... only once, in a dialog that allows me to select yet other javascripts with just a single keypress. Must have seen that somewhere (most likely on Peter Kahrel's site.).).

A good first thing to find out is whether PS's JS also can call doScript.

Known Participant
December 7, 2009

Thanks for that, especially the warning in the final par.

Saw the doScript in the InDesign dictionary, while Photoshop's appears

to sport only Do Action and Do Javascript!

So, maybe this is a blind alley for me.