maybe it is quite easy but I think I’m too stupid to understand how it works…
I want to switch the spelling dictionary in TextEdit. Here’s what I’ve done until yet…
run application "TextEdit"
tell application "System Events" to tell process "TextEdit"
set frontmost to true
keystroke (ASCII character 58) using command down
keystroke (ASCII character 9)
keystroke (ASCII character 9)
keystroke (ASCII character 9)
keystroke (ASCII character 9)
keystroke (ASCII character 32)
end tell
This should open the combo box in the spell checker window, but the problem is, that the window is not active and I dunno how to activate it, because I dunno what application or process it is…
Hopefully somebody can help me.
Regards
Tyraenor
Model: Mac mini 1.83Ghz, 1GB RAM
Browser: Firefox 2.0
Operating System: Mac OS X (10.4)
IMHO it’s impossible to do that.
With GUI-scripting you can open the floating window “Spelling” and
read the value of the popup button but setting it doesn’t work.
And there aren’t any UI elements of the popup button to click it
Here my attempt:
tell application "TextEdit" to activate
tell application "System Events"
if UI elements enabled then
tell process "TextEdit"
tell menu bar 1
tell menu bar item 4
tell menu 1
tell menu item 15
tell menu 1
click menu item 1 -- this opens the spelling window
end tell
end tell
end tell
end tell
end tell
tell window "Spelling" -- the german name is probably different
tell group 1
set theValue1 to value of pop up button 1
set value of pop up button 1 to "English"
set theValue2 to value of pop up button 1 -- this value never changes
set UI_Elements to UI elements of pop up button 1 -- the result is an empty list
end tell
end tell
end tell
else
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
end tell
end if
end tell
A workaround is to set the language popup menu manually to “Multilingual”
Model: G5 dual 2,5 GHz
Browser: Safari 419.3
Operating System: Mac OS X (10.4)
FWIW, this is all you need to get at the spelling menu:
tell application "System Events"
if UI elements enabled then
tell process "TextEdit"
keystroke ";" using {command down, shift down}
end tell
end if
end tell
I’m still looking at how to get at the rest…had a similar problem with the Find/Replace features…
[EDIT]Damn, that is bizarre…the Spelling window does not have focus when it opens (shame on you Apple!) so UI Browser can’t see it and any attempts to reference it blindly act like it isn’t there.
tell application "TextEdit" to activate
tell application "System Events"
tell process "TextEdit"
keystroke ";" using {command down, shift down}
tell window "Spelling"
tell group 1
tell pop up button 1
click
tell menu "OtherViews"
click menu item "English"
end tell
end tell
end tell
click button 1
end tell
end tell
end tell