I am very, VERY new to making apple scripts, and I’ve struggled to figure it out on my own, and tried tons of searches - and this is probably the most BASIC and SIMPLE stuff, but I can’t figure it out.
I want to run a script that will know where in my hard drive to find a document (it’s always in the same place), so following the path (how do I write the path in the script?) to the doc, then just opening it (yes, very basic, simple stuff), and then for it to do the following:
set firstText to text returned of (display dialog “Password” default answer “”)
tell application “tn3270 X” to activate
tell application “System Events”
keystroke “fi”
keystroke return
delay 2
keystroke "mcec "
keystroke firstText
keystroke return
delay 2
keystroke return
keystroke “*DEFINE”
keystroke return
end tell
I got it to do THIS much all by myself, basically just to log me into the system. IDEALLY I’d like to just launch the Applescipt and only type in my password there, and it would open the correct settings file (or preference doc or whatever it’s called), then log me in for me, and then take me to *DEFINE, where I normally go. One problem with the above code is that I have to first have the correct file already open. BUT, I want the script to open it for me instead of me opening it myself. In old Excel 4.0 macro vernacular I would use something like the following to pull up the directory: =DIRECTORY(“Hard_Drive:Applications:TN3270-OCSM-X:tn3270 3.2.4:ITS tn3270 X”) then I would just tell it to open (with the right application of course). I don’t know how to do that simple task in Applescipt (with OS X 10.4.11 if that matters).
I’m using Script Editor 2.1.1
So I just want the script to open the right preference file and then to log me in with the password the script asked me for.
THEN, once logged in, I want it to do a bit more. I sometimes have tons of screens to scroll through, and I’d like the script to take care of some of the redundancy. I understand some of the very basic “keystroke” commands that tell the script to type “this” word or “that” word to get to the right screens in the mainframe, so I can already write some of the code. BUT, what I want to do is have the script “hit the enter button” for me (I know that’s ‘keystroke return’) and then, and more importantly, “grab the next screen that displays” (don’t know how to do that) and keep doing this until some key word pops up on the “last” screen that lets it know it can stop grabbing screens. And somehow, this would magically produce a file filled with these “grabbed” screens. So it would have to be some sort of loop that it would somehow know how to get out of by reading what’s on each screen (so not just blindly capturing each screen). Normally, I might have it look for one word that would not appear anywhere on any of the screens except for the last screen, such as the word ‘end’. It could find the word ‘end’ in a sentence like ‘end of transactions’ or ‘End of list, please type in your next command.’ But I don’t know how that could be done. Ideally, it would just look everywhere and if it saw the word ‘end’ in any statement, anywhere on the entire screen, it would know to stop and get out of the “screen grabbing” loop.
I don’t know how to do this, or even just simply how to “grab” a screen, even just one screen. Would it capture the screen one single character at a time, reading in each line or row one at a time, or would it be some sort of copy and paste of the entire screen into some new doc, and still be able to tell when to stop? How would it create a new doc or file? It doesn’t really matter what the doc is called or named as long as I can find it, because I would then simply have an Excel macro open the newly-created file and do more stuff. The Excel stuff, I can do, as long as the applescript makes sure not to overwrite any previous doc it has created and always makes a doc with a new name. I would also like the option to have the script create a doc filled with 'grabbed screens" and know when to stop and then have another script be able to find and open that same file later and then ADD even more screens to the end of that same file or doc.
So, to my thinking, it might be just terribly easy and simple: One script would log me in. Then I would manually type in a particular command or go to a specific screen in the mainframe and simply run the ‘screen-grabber’ script.
And since my simple script above already works, it makes me think this whole thing is actually possible.
Thanks for any info or advice,
Henry
Model: PowerPC G4
AppleScript: 2.1.1
Browser: Firefox 3.0.10
Operating System: Mac OS X (10.4)