repeat 1 times
delay 0.2
-- Title
tell application "Keychain Access"
activate
tell application "System Events"
delay 0.2
keystroke return
delay 0.2
set the clipboard to "" -- required if the field is blank
-- if blank, ⌘C is not available and does nothing
-- if that did nothing, previous content is still in the clipoard
keystroke "c" using command down
end tell
end tell
delay 0.2
tell application "TextEdit"
activate
tell application "System Events"
delay 0.2
-- if the field contains the separator "," the field must get quoted
-- we quote always, because the field might contain a line break
-- if the field contains a double quote, it must get a pair of double-quotes
set AppleScript's text item delimiters to {"\""}
set myWord to the clipboard
set myParts to text items of myWord
set AppleScript's text item delimiters to {"\"\""}
set MyResult to myParts as string
set the clipboard to MyResult
keystroke "\""
keystroke "v" using command down
keystroke "\""
keystroke ","
end tell
end tell
-- URL
tell application "Keychain Access"
activate
tell application "System Events"
delay 0.2
keystroke tab
delay 0.1
keystroke tab
delay 0.1
keystroke tab
delay 0.2
set the clipboard to ""
keystroke "c" using command down
end tell
end tell
delay 0.2
tell application "TextEdit"
activate
tell application "System Events"
delay 0.2
set AppleScript's text item delimiters to {"\""}
set myWord to the clipboard
set myParts to text items of myWord
set AppleScript's text item delimiters to {"\"\""}
set MyResult to myParts as string
set the clipboard to MyResult
keystroke "\""
keystroke "v" using command down
keystroke "\""
keystroke ","
end tell
end tell
-- Username
tell application "Keychain Access"
activate
tell application "System Events"
delay 0.1
keystroke tab using shift down
delay 0.2
set the clipboard to ""
keystroke "c" using command down
end tell
end tell
delay 0.2
tell application "TextEdit"
activate
tell application "System Events"
delay 0.2
set AppleScript's text item delimiters to {"\""}
set myWord to the clipboard
set myParts to text items of myWord
set AppleScript's text item delimiters to {"\"\""}
set MyResult to myParts as string
set the clipboard to MyResult
keystroke "\""
keystroke "v" using command down
keystroke "\""
keystroke ","
end tell
end tell
-- Password
tell application "Keychain Access"
activate
tell application "System Events"
-- shortcut, see Menu → Edit → Copy Password to Clipboard
delay 0.2
keystroke "c" using {shift down, command down}
-- Type password - update to yours
delay 0.5
keystroke "password"
delay 0.2
keystroke return
end tell
end tell
delay 0.2
tell application "TextEdit"
activate
tell application "System Events"
delay 0.2
set AppleScript's text item delimiters to {"\""}
set myWord to the clipboard
set myParts to text items of myWord
set AppleScript's text item delimiters to {"\"\""}
set MyResult to myParts as string
set the clipboard to MyResult
keystroke "\""
keystroke "v" using command down
keystroke "\""
keystroke ","
end tell
end tell
-- Notes, last item; therefore "return" to next line at the end
tell application "Keychain Access"
activate
tell application "System Events"
delay 0.2
keystroke tab
delay 0.1
keystroke tab
delay 0.2
keystroke "a" using command down
delay 0.1
set the clipboard to ""
keystroke "c" using command down
end tell
end tell
delay 0.2
tell application "TextEdit"
activate
tell application "System Events"
delay 0.2
set AppleScript's text item delimiters to {"\""}
set myWord to the clipboard
set myParts to text items of myWord
set AppleScript's text item delimiters to {"\"\""}
set MyResult to myParts as string
set the clipboard to MyResult
keystroke "\""
keystroke "v" using command down
keystroke "\""
keystroke ","
keystroke return
end tell
end tell
tell application "Keychain Access"
activate
tell application "System Events"
-- Close keychain item window
delay 0.2
keystroke "w" using command down
-- Go to next keychain item
delay 0.2
key code 125
end tell
end tell
end repeat
end run