Applescript to move focus to active or next window
See if invoking with System Events doesn't override the scope of emacs/aquamacs.

tell application "System Events" to key code 48 using {command down}


If that still doesn't help, you can trap for it:

tell application "System Events"
    set theName to name of the first process whose frontmost is true
    if theName contains "emacs" then
        set frontmost of item -2 of (every process whose visible is true) to true
    else
        key code 48 using {command down}
    end if
end tell