Example of simple replacement for display dialog?

Can someone point me to or send me an example of how to use AppleScript Studio and Interface Builder to create a password entry dialog box to replace a call to display dialog?

I’m a complete AppleScript Noob, working on a last minute priority project to create a script to mount multiple volumes from our NetWare servers, so that the user only needs to type their password once rather than once per volume. I’ve managed to come up with a script that does everything needed, except that the display dialog command I’m using to request the user’s password displays the plain text on the screen for all to see.

I found 24U Appearance OSAX, but my boss understandably doesn’t want to spend $1000 for one dialog box. I’ve been pointed to both Smile and AppleScript Studio, but being a noob, they both make my head swim and I can’t really make heads or tails of how to get this done quickly in either. I guess that’s what I get for being old enough that my college CS classes were all in Pascal or C, and not having gotten around to learning OOP since then… :?

Anyway, this seems like it should be a really simple, straightforward task. Does anyone have an example they could point me to or send me that does this, or something similar that I can follow enough to figure out how it works? Alternately, is there an example similar to this in a book that I can go buy?

Any assistance would be greatly appreciated…


Greg Orman
Information Techology
Scripps College

It’s not difficult, though you need some AS-Studio knowledge.
Basically, drop a text field (NSTextField) to your window in Interface Builder. Select it and go to “Custom Class” (apple + 5). Pick “NSSecureTextField”.

Your window, by default, is set up to be “visible at launch time”. Hit “apple + 1” for window’s attributes.
Now, to know when the user entered his password and clicked “OK”, drop a simple button and label it “OK”. Go to AppleScript (apple + 6), and check both the “clicked” event and the main applescript (below).
Save and return to PB. Edit the script. You will see that it was added a new handler called “on clicked theobject”. Simply add anything such as this:

set userPassword to contents of text field 1 of window 1

And you are done!

Thanks, jj!