As always, I tried to edit your script so that it's no longer sticked to English.
At first look I assumed that it would be fine to replace the menu items triggering by use of shortcuts.
Alas, the engineers defined the related shortcuts as cmd + option + 0 (yes the zero) and cmd + 0 (zero again).
If my memory is right, they are OK on English system but when I run the system in French, 0 is reached by shift + à.
Given that, I dropped the use of shortcuts and triggered the menu items by their index.
--------------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2015/10/25 01:15
# dMod: 2015/10/25 01:30
# Appl: Mail, System Events
# Task: Toggle the Activity Window Open/Closed and bring focus back to the front Mail-Viewer.
# Tags: @Applescript, @Script, @Mail, @System_Events, @Toggle, @Activity, @Window, @Open, @Closed
# Note: Tested only on 10.11.1 with Mail in Classic-View.
--------------------------------------------------------------------------------------
(path to application "Mail") as «class furl»
set Activity_loc to localized string "5.title" from table "ActivityWindowController" in bundle (result)
try
tell application "System Events"
tell application process "Mail"
set frontmost to true
if (name of windows) does not contain Activity_loc then
(*
# They use awful shortcuts.
# on English system they would be :
keystroke "0" using {command down, option down}
keystroke "0" using {command down}
# On a French system they would be:
keystroke "à" using {shift down, command down, option down}
keystroke "à" using {shift down, command down}
*)
(*
log (get name of menu bar item 9 of menu bar 1)
*)
tell menu 1 of menu bar item 9 of menu bar 1
click menu item Activity_loc
click menu item 9
end tell
else
tell window 1
tell attribute "AXCloseButton"
click its value
end tell
end tell
end if
end tell
end tell
on error e number n
stdErr(e, n, true, true) of me
end try
Yvan KOENIG (VALLAURIS, France) dimanche 25 octobre 2015 12:10:04