Automatic Yahoo Mail Checker (Can switch keyboard layout also)

Script can check email from Yahoo Mail Account. It can switch keyboard layout also ( Turkish QWERTY PC / U.S. )

Thank you Stefan for your Help.


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 3

tell application "System Events"
	tell process "Safari"
		keystroke "your_email@yahoo.com"
		keystroke tab
		delay 0.5
		keystroke "your_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

Note: the handler to change the keyboard layout works only in Leopard

seems to be broken now