Looking for an AppleScript to access my Keychain

I want to write an AppleScript to search my keychain for keys whose name matches a certain pattern, and change their passwords. I’m having trouble because Keychain Scripting refuses to work properly - even when I give it something simple to match on, it’s failing.

Even this dies:

tell application “Keychain Scripting”
set myKey to (first Internet key of current keychain whose name starts with “a”)
end tell

It comes back with a Scripting Error: ‘Keychain Scripting got an error: Can’t get Internet key 1 of current keychain whose name starts with “a”.’

I don’t understand why this is happening. (Yes, I do have keychains whose names begin with ‘a’.) I even tried using a third-party library out there called “Usable Keychain Scripting”, but I wasn’t able to figure out how to get that to work at all.

Does anyone have any ideas on this, or would someone please give me or point me at a script that can find and manipulate keys on a keychain?

Model: G5
AppleScript: Latest
Browser: Safari
Operating System: Mac OS X (10.5)

I took a look at this and found that “starts with” or any other like wording doesn’t work. The only thing that worked is if I used “is”… but of course you don’t want that. So I suggest you do it like the following…

set searchTerms to "a"

tell application "Keychain Scripting"
	launch
	set myInternetKeys to every Internet key of current keychain
	set foundKeys to {}
	repeat with i from 1 to count of myInternetKeys
		set thisKeyName to name of item i of myInternetKeys
		if thisKeyName starts with searchTerms then
			set end of foundKeys to item i of myInternetKeys
		end if
	end repeat
end tell
foundKeys