I will made "Sans Titre 3" in background and "Sans titre" in foreground.
tell application "TextEdit"
set a to every window of application "TextEdit"
set b to item 1 of a --b is the foreground window, named "Sans titre 3", his index is 1
set c to count of a
set d to item c of a --d is the background window, named "Sans titre", his index is 3
set index of b to c --index of "Sans titre 3" becomes 3
set index of d to 1 --index of "Sans titre" becomes 1, so "Sans titre" must be in foreground
end tell
After the script, I have this :
(seeing from AppleScript Editor in foreground, this seems correct).
But, when, in Dock, I click to TextEdit, I see this :
Probably because the window "Sans titre 3" has keep his focus status, in spite of is index of 3.
I have tried to insert, before the "end tell" in previous script these lines :
tell application "System Events"
tell process "TextEdit"
set focused of window 1 to true -- window 1 is "Sans titre"
end tell
end tell
but this don't have the effect.
I tryed also with :
set value of attribute "AXFocused" of window 1 to true
but no effect either.
Can you say how I can made this?
Thanks
(under Leopard 10.5.7).