Unlocking applications

Hi,
I am trying to script Directory Access and I can get the application to activate, but the lock is activated and needs to be unlocked before I can even look at scripting any of the rest of the application.

Is there a way that I can check if the application is locked and if so, how to unlock it, passing the appropriate password.

Thanks for any advice you can offer,

Liz

Apple doesn’t make this easy, and probably for good reason. It’s simple enough to figure out whether the lock needs to be pressed, but getting through the authentication dialog is a bit trickier. AFAIK the dialog can’t be targeted using conventional methods, and so has to be dealt with in keystrokes. Even then, there is an automatic delay imposed on the keystroke, and you can’t press the return key. I discovered, however, that you can cycle back to the OK button and hit space. This might just be a temporary oversight/bug on the Apple side though.

tell application "System Events" to tell process "Directory Access" to tell window 1
	tell application "Directory Access" to activate
	if name of button 4 contains "make" then
		click button 4
		keystroke "mycleverpassword"
		keystroke tab using shift down
		keystroke tab using shift down
		keystroke space
	end if
end tell