Applescript - activate background application doesn't work
I think the problem is..  Telling an application to activate, is handled by "Standard Additions", but you are asking "System Events" to handle that action. 

tell application "System Events" to set AppName to name of ¬
    every process whose background only is false
tell application (some item of AppName) to activate