Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Adding and changing order of Keychains

I would like to be able to write a script to add a new Keychain before my "login" Keychain. I can't even get this to work from terminal. Any help would be appreciated.


Thanks

MacBook Pro, OS X Yosemite (10.10.3), null

Posted on Jun 15, 2015 9:18 AM

Reply
19 replies

Jun 29, 2015 10:31 AM in response to dvrose

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:

User uploaded file


Then open the Contents folder and move a copy of cliclick into the Resources folder of the package (inside the Contents folder):User uploaded file

Finally, you must grant access to the new application in Security & Privacy preferences, located in System Preferences.




Adding and changing order of Keychains

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.