International in System Preferences, 10.4.3

I’m fairly new to scripting, and I am reimaging several iMacs, so here’s what I’d like to do:

I’d like to run a script that allows all keyboard layouts to be selected in the ‘Input Menu’ of the ‘International’ pane in System Preferences. I have enabled access for assistive devices in ‘Universal Access’ and I have copied a script provided by Jacques in another thread, but I haven’t been able to manipulate it correctly:

tell application "System Preferences"
	set current pane to pane id "com.apple.Localization"
	tell application "System Events" to tell application process "System Preferences" to tell window "International"
		click radio button "Input Menu" of tab group 1
		set this_rows to rows of table 1 of scroll area 1 of tab group 1
		repeat with i in this_rows
			if value of checkbox 1 of i is 0 then
				select i
				click checkbox 1 of i
			end if
		end repeat
	end tell
end tell

I get AppleScript Error ‘NSReceiverEvaluationScriptError: 4’ when I run it. Any suggestions/corrections?

Row 4 doesn’t have a checkbox. I think the easiest way around this is to use a “try” block:

tell application "System Preferences"
	activate
	set current pane to pane id "com.apple.Localization"
	reveal (first anchor of current pane whose name is "InputMenu")
end tell

tell application "System Events"
	launch
	tell window 1 of process "System Preferences"
		get rows of table 1 of scroll area 1 of tab group 1
		repeat with thisRow in (result)
			try
				if (value of checkbox 1 of thisRow) is 0 then
					select thisRow
					click checkbox 1 of thisRow
				end if
			end try
		end repeat
	end tell
end tell

quit application "System Preferences"

This will effectively skip any errors that occur while dealing with the checkboxes.

Thanks, that did the trick!