program is jumpy after keystroke return -- scripting vpn + volume

I’m trying to automate the process of connecting to a Cisco VPN and mounting multiple volumes. What i have almost satisfies me, but there’s a minor problem:

I need to enter a password and press the “OK” button. I do that with the clipboard and return key. However, after “keystroke return”, the application does a jumpy minimization and expansion that leaves the same window open with the password entry blank and no VPN connection being made. It’s more like “return” was an “undo”.

tell current application
	set the clipboard to "[password]"
end tell
tell application "VPNClient"
	activate
end tell
--The app opens a window with username present and the cursor on the password entry area
delay 0.2
--paste password
tell application "System Events"
	set frontmost of process "VPNClient" to true
	keystroke "v" using command down
	keystroke return
end tell
--the app immediately makes its jumpy moves
delay 4

--the following works great and is based on the passwords already being in the keychain
tell application "Finder"
	mount volume "smb://username1@server/volume"
	mount volume "smb://username2@server/volume"
end tell

So how can i make the “ok” work better?

Thanks!

Model: MacBook Pro
AppleScript: 2.0.1
Browser: Firefox 3.5.2
Operating System: Mac OS X (10.5)

I got this to work by forgetting about the clipboard method and just keystroking the password i need. This cisco vpn client stinks, by the way.

Now i’m using SL with it’s built-in VPN management, so i get to write a new script now.

This is the one that works:

tell application "VPNClient"
	activate
end tell
delay 0.2
tell application "System Events"
	delay 1
	keystroke "[password]"
	keystroke return
end tell

tell application "Finder"
	mount volume "smb://username1@server/volume1"
	mount volume "smb://username1@server/volume2"
end tell