AppleScript for allowing multiple Apple iTunes User Account on a machine
tell application "Keychain Scripting"
set myKeyChain to current keychain
set theKeyList to every generic key of myKeyChain whose description is "iTunes innlogging"
end tell
set theKeyNamesList to {}
repeat with x in theKeyList
copy name of x to the end of theKeyNamesList
end repeat
set selectedKey to text of button returned of (display dialog "Velg hvilken konto du vil logge inn med:" buttons theKeyNamesList)
tell application "Keychain Scripting"
repeat with x from 1 to (length of theKeyList)
set theKey to item x of theKeyList
if the name of theKey is selectedKey then
set thePassword to password of theKey
set theUserID to the account of theKey
end if
end repeat
end tell
tell application "System Events"
tell process "iTunes"
set frontmost to true
try
click menu item "Logg av" of menu "Butikk" of menu bar item "Butikk" of menu bar 1
end try
click menu item "Logg p�¥â�¦" of menu "Butikk" of menu bar item "Butikk" of menu bar 1
keystroke theUserID
keystroke tab
keystroke thePassword
keystroke return
delay 3
keystroke return
end tell
end tell