First of all, copy the following script into a new Script Editor window, then save it as an application by choosing “Application” in the File Format popup button.
set theKeychain to "My New Keychain"
set thePassword to "My New Password"
tell application "Keychain Access"
activate
repeat until frontmost is true
end repeat
end tell
tell application "System Events" to tell process "Keychain Access"
tell menu bar 1
clickmenu item "Keychain Viewer" of menu 1 of menu bar item "Window"
if existsmenu item "Show Keychains" of menu 1 of menu bar item "View" then ¬
keystroke "k" using {command down}
end tell
set theOutline to outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window 1
set theValue to (characterid 65532) & space & space & theKeychain
if (exists (row 1 of theOutline whose value of text field 1 is theValue)) then return
keystroke "n" using {option down, command down}
delay 1
keystroketheKeychain & return
delay 1
keystrokethePassword & tab & thePassword & return
set {x, y} to position of row 1 of theOutline whose value of text field 1 is theValue
set x to x + 21
set n to 0
repeat with thisValue in (get value of text field 1 of rows of theOutline)
if thisValue contains theKeychain then exit repeat
set n to n + 1
end repeat
end tell
set cliclick to quoted form of POSIX path of (path to resource "cliclick")
do shell scriptcliclick & " dd:" & x & "," & y & " du:" & x & "," & (y - n * 20)
-- tell application "System Events" to keystroke "q" using {command down} -- optional
Then control click the application icon and click the “Show Package Contents” menu item:
Then open the Contents folder and move a copy of cliclick into the Resources folder of the package (inside the Contents folder):
Finally, you must grant access to the new application in Security & Privacy preferences, located in System Preferences.