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!
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)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)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)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)(no subject)
Date: 2007-02-22 06:11 pm (UTC)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.