pasithea: glowing girl (Default)
[personal profile] pasithea
Go ahead. Google search. Just TRY to find a reference page for Applescript programming. I DARE you.

I spent my whole evening futzing with voice commands for photoshop and illustrator. I wonder if I'll ever do enough keypresses in them to pay off the eight hours I just spent doing the scripting.

Of course, the frustrating thing was that I wanted to de fairly basic simple stuff and it's completely totally undocumented.

Like okay... Often you get a dialog box that has an OK or Cancel.

In theory, the code looks like this:
tell current window click button "OK"

Of course, that doesn't actually work. In fact, I couldn't get any of the 'click button' type commands to work (though I was able to get menu items to basically work)

Anyhow. For 90% of my stuff,
tell application "System Events" to keystroke return
works well enough for most OK cases and it's just generally handy anyhow.

Now Cancel...
There is no 'keystroke escape' and something clever like 'keycode 27' (The ASCII value for escape) also doesn't work.

Ugh. I spent hours on this. As common as the OK and Cancel buttons are, you'd THINK there'd be a well-defined handler for them that everyone uses but tons and tons of searching lead me to the conclusion that everyone who uses applescript has this problem and no one has a solution to it.

I finally discovered that CTRL-OPT-APPLE-[ works like cancel for the few most irritating Photoshop windows.

Speaking of Photoshop... It has it's own library of applescript commands you can use in it and it's just as poorly documented as Applescript itself.
While I fairly quickly figured out how to create a new layer, name it, and set its transparency mode with a single voice command (which is cool) I had NO LUCK at all finding a way to LOCK a layer. The word 'lock' isn't even mentioned in the applescript document for Photoshop. I can toggle the visibility, swap the order of the layers, monkey with the channels, but there is no info ANYWHERE on how to lock the layer with applescript (or Java script or Visual Basic, I would have adapted!)

So that's been my evening. Those two things were just maddening. Everything else went together without too much fuss, and I think it really is going to work out well for me. Nothing slows me down like fumbling for keys and trying to remember where something was in some menu.

I really do wish AppleScript was better documented though. Just a list of commands and valid parameters. That's all I'm asking for here. I can figure out what they do, but without knowing the commands, it's a real pain in the ass!

(no subject)

Date: 2007-02-22 11:14 am (UTC)
From: [identity profile] cortezopossum.livejournal.com
There was an AppleScript reference guide book out there I was thinking of getting that supposedly was a good reference guide (90% of all computer books are worthless garbage so it's a real crapshoot) but when my mac died I stopped looking for it.

I agree though, most guides I've seen have been woefully inadequate. You almost have to learn the language entirely by looking at example programs, which is a really stupid way to learn a computer language.

(no subject)

Date: 2007-02-22 12:43 pm (UTC)
ext_646: (iCoon)
From: [identity profile] shatterstripes.livejournal.com
In the script editor, you can do 'open dictionary' and pick an app. They're supposed to document themselves. You also get the docs for the standard suite of commands no matter what app's dictionary you open.

There's docs in the dev tools install: Here.

And these led me to the specs of the language on developer.apple.com.

This page on Mac speech recognition (quite possibly the one that spurred you playing with this) has some notes in the comments about how to get keycodes.

Layer lock in Photoshop appears to be a read-only property of a layer. However, a little testing reveals that you can record Photoshop actions that frob a layer's lock state, and you do appear to be able to fire off actions from the Applescript interface.

(no subject)

Date: 2007-02-22 06:43 pm (UTC)
From: [identity profile] dv-girl.livejournal.com
Ah-HA! _NOW_ the library has stuff in it.

Photoshop 7 didn't come with Applescript installed by default. I had to find a library for it and install it.

However, there was a library entry for Photoshop. It just had only 2 functions defined in it and annoyed the piss out of me.

(no subject)

Date: 2007-02-22 03:18 pm (UTC)
From: [identity profile] barberio.livejournal.com
Apple have a whole raft of documentation at http://www.apple.com/applescript/resources/

(no subject)

Date: 2007-02-22 06:11 pm (UTC)
From: [identity profile] yetanotherbob.livejournal.com
Oh wow. Raft indeed. Adobe scripting forum. I'm going to have to bookmark this. And this and this and this.

Heh. I actually haven't done much with applescript, as trying to find the right preposition throws me off. I do know that from the other side, it's even worse; That is, making an app to support it is rather hairy. Cocoa requires several xml files and bridging functions, and Carbon, well, it's just more apple event handlers. It's not impossible, per se, but there's a distinct lack of tools for creating these xml files, and I've yet to find good full templates.

February 2012

S M T W T F S
   1234
567891011
12 131415161718
19202122232425
26272829   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 1st, 2026 10:02 am
Powered by Dreamwidth Studios