Can anyone tell me how to target a specific text field within TextEdit’s paragraph spacing dialog?
After I have selected all text in a document using GUI scripting, I am then able to opening the paragraph spacing menu using the following:
activate application "TextEdit"
tell application "System Events" to tell process "TextEdit"
keystroke "a" using {command down}
click menu item "Spacing..." of menu "Text" of menu item "Text" of menu "Format" of menu bar item "Format" of menu bar 1
I would then like to target the “after” text field to change its value to something other than the default value “0.0”. However, there are a several challenges I’ve faced when trying to do this:
- From using a UI Browser it seems that all the text fields have no label with which to target them
- When the paragraph spacing dialog has opened, the currently selected text field is not necessarily always the first one (it will be whatever it was last time - unless Text Edit has just been opened). This is why using keystroke tab (x4) won’t work.
- Text field indexes don’t seem to work, probably due to the point directly above.
I thought one possible solution would be to check the value of each text field in turn until the value “1.0” is found (knowing that the first text field is always “1.0” by default, whilst all others are “0.0”), and then using keystroke tab the required number of times to get to the “after” text field.
There may be a more elegant solution, but if this is the only way to do it, im not sure how to make the script to cycle through the text fields to check for the value “1.0” as they don’t seem identifiable. For example, something like the following didn’t work for me:
set x to 0
repeat until myVal = "1.0"
....
set x to x + 1
set myVal to (get value of text field x)
end repeat
Model: Macbook Pro
AppleScript: 2.0
Browser: Firefox 2.0.0.12
Operating System: Mac OS X (10.5)