Jump to content

Anyone can help with this iTunes accounts switching Applescript?


Recommended Posts

Hi,

 

I found a useful applescript here. It allows to switch iTunes accounts in one sec. Very useful to those who have multiple iTunes accounts.

 

Anyone can help craft the codes to make it compatible with Alfred?

 

Thanks in advance.

 

Here's the code.

set _delay to 1
set newLogin to button returned of (display dialog "Select account:" buttons {"Country 1", "Country 2"} default button "Country 1")
set thisApp to button returned of (display dialog "Which Store?" buttons {"iTunes", "App Store", "Cancel"} default button "iTunes")
if newLogin is "Country 1" then
    set newLogin to "email 1"
    set newPass to "password 1"
else if newLogin is "Country 2" then
    set newLogin to "email 2"
    set newPass to "password 2"
end if
if thisApp is "App Store" then
    tell application "System Events"
        tell process "App Store"
            set frontmost to true
            delay _delay
            try
                click menu item "Sign Out" of menu 1 of menu bar item "Store" of menu bar 1
            end try
            delay _delay
            click menu item "Sign In…" of menu 1 of menu bar item "Store" of menu bar 1
            delay _delay
            keystroke newLogin
            keystroke tab
            keystroke newPass
            keystroke return
            delay 4
            keystroke return
        end tell
    end tell
else if thisApp is "iTunes" then
    tell application "System Events"
        tell process "iTunes"
            set frontmost to true
            delay _delay
            try
                click menu item "Sign Out" of menu 1 of menu bar item "Store" of menu bar 1
            end try
            delay _delay
            click menu item "Sign In…" of menu 1 of menu bar item "Store" of menu bar 1
            delay _delay
            keystroke newLogin
            keystroke tab
            keystroke newPass
            keystroke return
            delay 4
            keystroke return
        end tell
    end tell
end if
Edited by homever
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...