Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Am3822

macrumors 6502
Original poster
Hi all,

I have an annoying problem with X11.app (and a few other applications). If I launch it while I'm using Hebrew keyboard layout, it's unusable unless the layout is changed from the menubar.

Is there a way to write an applescript 'wrapper' that would change the keyboard layout selection to English and then launch an application?
 
Found this over at Apple Discussions (Hiroto) that seems to work on my computer. Obviously change British to whatever you want and iTunes.

It is possible to modify it to watch form X11 to close and then revert back to hebrew

Code:
try
	script o
		tell application "System Events" to tell process "SystemUIServer"
			set _ to get value of attribute "AXDescription" of every menu bar item of menu bar 1
			set {k, j} to {count of _, 0}
			repeat with i from 1 to k
				if _'s item i is "text input" then
					set j to i
					exit repeat
				end if
			end repeat
			
			if j > 0 then
				tell menu bar item j of menu bar 1
					click
					tell menu 1
						click menu item "British"
					end tell
				end tell
			end if -- j > 0
		end tell -- to process and System Events
		tell application "iTunes" to activate
	end script
on error
	display dialog "An unexpected error"
end try
run script o
--END OF SCRIPT
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.