In my script below, the buttons are being pressed and the resulting “Set” is on my desired result. The dialog then closes as it should. However, when I reopen “Edit > Keyboard Shortcuts” the set chosen did not stick? Can anybody shed some insight as to why this might be. The code is very simple.
Thanks,
-Jeff
tell application "System Events"
	tell application process "Adobe InDesign CS4"
		set frontmost to true
		tell menu bar 1
			tell menu bar item "Edit"
				tell menu 1
					click menu item "Keyboard Shortcuts..."
				end tell
			end tell
		end tell
		repeat with i from 1 to count of pop up buttons of window 1
			set presetValue to get value of pop up button i of window 1 as string
			if presetValue is not "Default" and presetValue is not "Application Menu" then
				set myButton to i
				exit repeat
			end if
		end repeat
		
		click pop up button i of window 1 --open menu "Sets"
		
		--Move up the list to make sure it's on [Default]
		keystroke (ASCII character 30) -- up arrow key
		delay 0.1
		keystroke (ASCII character 30) -- up arrow key
		delay 0.1
		keystroke (ASCII character 30) -- up arrow key
		delay 0.1
		keystroke (ASCII character 30) -- up arrow key
		delay 0.1
		keystroke (ASCII character 30) -- up arrow key
		delay 0.1
		keystroke (ASCII character 30) -- up arrow key
		delay 0.1
		
		--Click on "[Default]" to temporarily set it
		keystroke (ASCII character 3) -- enter key
		delay 0.1
		
		repeat with i from 1 to count of pop up buttons of window 1
			set presetValue to get value of pop up button i of window 1 as string
			if presetValue is not "Default" and presetValue is not "Application Menu" then
				set myButton to i
				exit repeat
			end if
		end repeat
		
		click pop up button i of window 1 --open menu "Sets"
		
		
		--Go down 5 times to ensure it's now on the  Graphics key set.
		keystroke (ASCII character 31) -- down arrow key
		delay 0.1
		keystroke (ASCII character 31) -- down arrow key
		delay 0.1
		keystroke (ASCII character 31) -- down arrow key
		delay 0.1
		keystroke (ASCII character 31) -- down arrow key
		delay 0.1
		keystroke (ASCII character 31) -- down arrow key
		delay 0.1
		keystroke (ASCII character 31) -- down arrow key
		delay 0.1
		
		--Click Enter to set "Graphics" which should be the last item
		keystroke (ASCII character 3) -- enter key
		
		--Close the dialog
		keystroke (ASCII character 13) -- enter key
		
	end tell
end tell