UI scripting process "CharacterPalette" any way to select static text?

I’m trying to write a script part of which uses “CharacterPalette”. After many frustrated attempts, I’m stuck on the last line that uses this wholly unscriptable application. What I’m trying to do is select the last row of a list that pops up when you place a character (a big list with some characters, such as ‘a’ and ‘e’) into the search text field at the bottom next to the “Insert” button. I’ve tried a bunch of things:

 1) The only method that works is keypress the down arrow a bunch of times then keystroke return, but that's a bit slow and if [i]"CharacterPalette"[/i] does not stay frontmost, it won't work. Not only that but it seems the return isn't sent to the right place as I have it so the list never disappears. A better solution would be Here's the portion that I'm having a problem with:

 2) Double-clicking at {x,y} near the text field... seems the clicks don't register.
      2a) I've tried playing around with [i]"call method"[/i] to get the click to register, but can't seem to tell "System Events" and "AppleScript Runner" at the same time.

 3) The [b]best[/b] solution would be to select the bottom row somehow, but don't know if a static text can be selected. There doesn't seem to be "normal" list elements (like rows) associated with this list.
      3a) Since I couldn't figure out how to select the row, I tried enabling it, and setting focused to true to no avail.

Here’s the portion of code that contains the problem:

PasteCopiedCharacter("e")

on PasteCopiedCharacter(copiedchar)
	tell application "System Events" to tell application process "CharacterPalette"
		tell window "Characters" to tell group 1 to tell (the first text field whose description is "search text field")
			set {position:SFPosition, size:SFSize} to properties --> #2) This attempt is to click using the mouse pointer
			if copiedchar is not equal to the value then set the value to copiedchar
		end tell
		set x to ((item 1 of SFPosition) + ((item 1 of SFSize) / 2)) as integer --> #2) x-coordinate of row
		set y to ((item 2 of SFPosition) + ((item 2 of SFSize) / 2) - 24) as integer --> #2) y-coordinate of row
		set enabled of properties of static text 2 of list 1 of window 1 to true --> #3a) enabled or focused don't seem to ...
		set focused of properties of static text 2 of list 1 of window 1 to true --> #3a) ... be the right words
		tell application "AppleScript Runner" to call method "NSNegateBooleanTransformerName" of class "NSString" with parameter enabled --> #3a) I know nothing about obj-c methods so just playing around
		with timeout of 1.5 seconds
			repeat until list 1 of window 1 exists
				delay 0.1
			end repeat
		end timeout
		tell application "CharacterPalette" to activate
		delay 0.1
		if list 1 of window 1 exists then
			set LastRow to "last static text whose name is \"row\""
			tell application "AppleScript Runner" to tell window 1 to tell list 1 to call method "performClick:" of LastRow --> #2a
			tell application "AppleScript Runner" to call method "performClick:" with parameters {x, y} --> #2a
			--	tell application "Applescript Runner" to tell window 1 to tell list 1 to tell (last static text whose name is "row") to call method "performClick:" of object (static text "row") --> #2a) Won't even compile
			click at {x, y} --> #2) doesn't select the last row even though the {x,y} coorinates are right
			keystroke (ASCII character 31) --> #1) Down arrow a bunch of times ...
			keystroke (ASCII character 31) --> #1) ... works right up until the ...
			keystroke (ASCII character 31) --> #1) ... keystroke return, which ...
			keystroke (ASCII character 31) --> #1) ... doesn't show the character ...
			keystroke (ASCII character 31) --> #1) ... Also, slow and worst way to ... 
			keystroke (ASCII character 31) --> #1) ... solve the problem ...
			keystroke return --> #1) ... What if list is longer than 6 rows? or 20 rows?
			
			(*     Some more testing:     *)
			tell window 1 to tell list 1 --to tell (the last static text whose name is "row")
				set counter to 1
				set props to {} as list
				repeat with i from 1 to (count of (every static text whose name is "row"))
					set {enabled:a, focused:b, selected:c} to (static text i's properties)
					set {enabled:a, focused:b, selected:c} to (static text i's properties)
					set props to props & {counter, a, b, c} as list
					set counter to (counter + 1)
				end repeat
				return props as list
			end tell
			set enabled of properties to true --> #3a) nope ...
			set focused of properties to true --> #3a) nope ...
			set selected of properties to true --> #3a) nope ...
		else
			keystroke return
		end if
	end tell
end PasteCopiedCharacter

Any suggestions?

One final thing, I don’t remember this list popping up always… maybe if a character only has one choice, there is no list. Or perhaps the latest upgrade to OSX 10.6.8 or Xcode4 is required if you don’t get the list (but I’m not 100% about this).

Model: iMac 7,1
AppleScript: AppleScript 2.1.2
Browser: Firefox 5.0
Operating System: Mac OS X (10.6)

Hey everyone! It’s been a couple of weeks now since I posted this question and haven’t heard a peep from anyone since… it can’t be too difficult to figure out, can it?

Anyway, this is me, bumping this question up to the forefront again incase someone who knows the answer missed it the first time around. :slight_smile:

Aesthir

You know that CharacterPalette was completely overhauled in Lion, right? I’ve had a script like this on my todo list for ages, but I’ve been waiting for 10.7 before starting to work on it.