How to merge these 2 different scripts

Friends,

How to merge these 2 script… For example the user have 10 different email account and all account needs to open in new tabs next to each other.

Here are scripts we need to merge together.


Script 1.

– an applescript program that opens a list of urls in separate tabs.
– opens safari, then loads each url in a separate tab.
– written by alvin alexander, devdaily.com
– no rights reserved, feel free to copy and improve this program.

set urlList to {“https://my.screenname.aol.com/_cqr/login/login.psp?sitedomain=sns.webmail.aol.com&lang=en&locale=us&authLev=0&siteState=ver%3A4|rt%3ASTANDARD|ac%3AWS|at%3ASNS|ld%3Awebmail.aol.com|uv%3AAOL|lc%3Aen-us|mt%3AAIM|snt%3AScreenName&offerId=mail-second-en-us&seamless=novl”, “http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=10&ct=1233241098&rver=5.5.4177.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx%3Fn%3D540237836&id=64855”, “http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=10&ct=1233241098&rver=5.5.4177.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx%3Fn%3D540237836&id=64855”, “http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=10&ct=1233241098&rver=5.5.4177.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx%3Fn%3D540237836&id=64855”, “http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=10&ct=1233241098&rver=5.5.4177.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx%3Fn%3D540237836&id=64855”, “http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=10&ct=1233241098&rver=5.5.4177.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx%3Fn%3D540237836&id=64855”, “https://login.yahoo.com/config/login_verify2?&.src=ym”, “https://login.yahoo.com/config/login_verify2?&.src=ym”, “https://login.yahoo.com/config/login_verify2?&.src=ym”, “https://login.yahoo.com/config/login_verify2?&.src=ym”}
set numURLs to (count urlList)

tell application “Safari”
activate
– create all the tabs that are needed
tell application “System Events”
– enter the url in the open window
keystroke (item 1 of urlList)
key code 36
repeat with i from 2 to (numURLs)
– for each additional url, first create a tab
tell process “Safari”
click menu item “New Tab” of menu “File” of menu bar 1
end tell
– now enter the url
keystroke (item i of urlList)
key code 36
end repeat
end tell
end tell

Script 2.

set oldLanguage to changeInputLanguage(“U.S.”)

tell application “Safari”
activate
make new document
set URL of document 1 to “https://login.yahoo.com/config/login_verify2?&.src=ym
end tell

delay 7

tell application “System Events”
tell process “Safari”
keystroke “My_Email@yahoo.com
keystroke tab
delay 0.5
keystroke “My_Password”
delay 1
keystroke return
end tell
end tell
changeInputLanguage(oldLanguage)

on changeInputLanguage(l)
tell application “System Events” to tell process “SystemUIServer”
tell (1st menu bar item of menu bar 1 whose value of attribute “AXDescription” is “text input”)
set v to its value
click
delay 0.2
click menu 1’s menu item l
delay 1.0
return v
end tell
end tell
end changeInputLanguage

I will be thankfull from now on to anyone who can help me.

Bests,

Skysurfer,

I did it. But !! The problem is when you login to web based email account for example : my_username@hotmail.com
there is no problem to login, until you ( meaning script ) trying to log in to another hotmail account
( my_username2@hotmail.com) without logout from first 1. It is easy to see more than explain here. Try and see your self what happened. Anyone have an idea. So Please…


set oldLanguage to changeInputLanguage(“U.S.”)

tell application “Safari”
activate
make new document
set URL of document 1 to “https://login.yahoo.com/config/login_verify2?&.src=ym
end tell

delay 7

tell application “System Events”
tell process “Safari”
keystroke “My_Username@yahoo.com
keystroke tab
delay 0.5
keystroke “My_Password”
delay 1
keystroke return
end tell
end tell

delay 7

tell application “System Events”
tell process “Safari”
click menu item “New Tab” of menu “File” of menu bar 1
keystroke “http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&ct=1254082783&rver=6.0.5285.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&lc=1055&id=64855&mkt=tr-tr
keystroke return
end tell

delay 7

tell application "System Events"
	tell process "Safari"
		keystroke "My_Username@hotmail.com"
		keystroke tab
		delay 0.5
		keystroke "My_Password"
		delay 1
		keystroke return
	end tell
end tell

end tell

delay 7

tell application “System Events”
tell process “Safari”
click menu item “New Tab” of menu “File” of menu bar 1
keystroke “http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&ct=1254082783&rver=6.0.5285.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&lc=1055&id=64855&mkt=tr-tr
keystroke return
end tell

delay 7

tell application "System Events"
	tell process "Safari"
		keystroke "My_Username@hotmail.com"
		keystroke tab
		delay 0.5
		keystroke "My_Password"
		delay 1
		keystroke return
	end tell
end tell

end tell
on changeInputLanguage(l)
tell application “System Events” to tell process “SystemUIServer”
tell (1st menu bar item of menu bar 1 whose value of attribute “AXDescription” is “text input”)
set v to its value
click
delay 0.2
click menu 1’s menu item l
delay 1.0
return v
end tell
end tell
end changeInputLanguage
changeInputLanguage(oldLanguage)

No one ? Perfect…