How to maintain focus on app window with AppleScript
Try sending the Activate command outside the System Event tell, that would be the standard method.

tell application "Canon MX510 series" to activate
my testAppRunning()
tell application "System Events"    
    key code 20 using command down
end tell

on testAppRunning()
    set test to 0
    repeat while test = 0
        log test
        tell application "System Events" to set test to count (every process whose name is "Canon MX510 series")
        delay 2
        --/*we do this even if active because it doesn't naturally come to front*/
        try
            tell application "Canon MX510 series" to activate
        end try
        if (test &gt; 0) then exit repeat
    end repeat
end testAppRunning