Created Service to change Dictation Language automatically
Dear All,
With the introduction of Mountain Lion we now have a dictation tool that works well (based on Siri speech recognition). It is for me the best improvement of Mountain Lion as it will increase my productivity in mail and documents during work. However, for my work I have to write mails in Dutch, German and English which means I'll have to change between dictation languages all the time. This is a cumbersom task and for this I've written an AppleScript.
This is what I came up with after 1 day of frustration (I'm completely new to AppleScript):
tell application "System Preferences"
activate
end tell
delay 0.5
tell application "System Events"
tell process "System Preferences"
click menu item "Dictation & Speech" of menu "View" of menu bar 1
tell window "Dictation & Speech"
clickradio button "Dictation" of tab group 1
tell tab group 1
#return value of attribute "AXValue" of pop up button 1
if get value of attribute "AXValue" of pop up button 1 contains "English (United States)" then
tell pop up button 1
click
tell menu 1
click menu item "German"
say "Dictation set to German"
end tell
end tell
else if get value of attribute "AXValue" of pop up button 1 contains "German" then
tell pop up button 1
click
tell menu 1
click menu item "English (United States)"
say "Dictation set to English"
end tell
end tell
end if
end tell
end tell
end tell
end tell
tell application "System Preferences"
quit
end tell
So, after I put this into Automator as a AppleScript to be run as a service I've added in System Preferences\Keyboard\Services a Shortcut to run the script within any application (Mail for example).
All works well, so maybe I'll make someone else happy with my effort (this is also the reason for this somewhat extended introduction and me putting the script in the Mountain Lion forum).
Now my question:
-> If I run the service in Mail, I'll return to the desktop, the system preference change is performed and thereafter I don't return to the mail application. Does anyone know the AppleScript I need to add to make this happen?
I look forward to any reply / help.
Kind regards,
Dennis
MacBook Pro, Mac OS X (10.6.7)