This is probably very easy, but since I’m a noob…
What I’ve done so far:
I get Applescript to open Terminal, then using System Events, it logs into another terminal and does some pretty basic stuff - just some simple unix commands.
One of these is vi .hi - which tells the vi editor to open the document .hi and then I replace a single character in that doc.
The lines in Applescript are basically :
keystroke “vi .hi”
keystroke return
delay 1
keystroke “xak” --where ‘x’ deletes the existing character (because now I’m in the vi editor), ‘a’ then puts me in edit mode, and finally the character “k” is actually typed into the doc.
And that works just fine - only next time, I want the “k” to be an “l”, then the next time an “m” and on and on. So, what I do now is to just go in and edit my little Applescript and manually change the line: keystroke “xak” to keystroke “xal”. It works, but not very elegant.
What I want to do:
Have Applescript read the existing character (there’s only the one character in the whole doc anyway).
Then have Applescript know which character to replace it with and then go and replace it. So, if it finds a “k” there, it’ll replace it with an “l”. In other words, “a” is replaced with a “b”, “y” is replaced with a “z”, and “z” is replaced with an “a”, etc., etc.
Sorry if this is a dumb question - but it sounds like it should be easy to do.
I just don’t know how to get Applescript to read and recognize a character inside Terminal. Do I have to get out of “System Events” briefly for that part?
Thanks for reading this question and for any ideas!
Model: PowerPC G4
AppleScript: 1.9.3
Browser: Firefox 2.0.0.14
Operating System: Mac OS X (10.3.9)