Reading from a text field

Ok,

Hi,
I was wondering how you could read a text field, like if you had two fields one for username and one for password could applescript use whats typed in those certain boxes as a keystroke event? Example: A user types the username “raptor” and the password “lol” in the two textfields can applescript read from those and do something like

keystroke "raptor"
keystroke "lol"

So really like a login box? But use the name/password the user provided to keystroke it somewhere else.

Don’t worry it’s not a keylogger or something like that haha its just to have users log in to a database through this program.

It sure sounds like one.

I can’t figure out why else you’d want to do something like this. Please explain.

If you’re doing this yourself (e.g. not reading from another application, but one you made), you’ll need to go to AppleScript Studio, because the normal display dialog command can only display one text box at a time. In AS Studio, reading text fields is as simple as:

set uName to contents of text field "usr" of window "main"
set pWord to contents of text field "pword" of window "main"

And you would of course replace the names of the text fields and window with the actual names.

Reading text from login windows of other applications is probably quite a bit harder. I doubt many applications added scriptability to those places.

Thanks XP noob,

As far as what it does, it uses the login and password you provide to log you into a database :slight_smile:

XP noob with your script I always get the error "Expected end of line, etc. but found “.” It always picks up on the “of text field "pass”

That code is for AppleScript Studio, which is part of Xcode.

I acutually figured it out , needed “tell application XXX”