tell application "Keychain Scripting"
set myTestPassword to the name of every key of keychain 1 whose name is "myTestPassword"
end tell
tell application "Keychain Scripting"
tell keychain 1
set chosenKey to the first generic key whose name is (myTestPassword as string)
set chosenPassword to the password of chosenKey
end tell
end tell
-- do something with your password
tell application "SystemUIServer"
display dialog chosenPassword
end tell
I haven't done anything with a password in this way for a long time so I suspect there are much better scripts written. I hope this helps.