Not with a script, no. Maybe by using a plugin.
For fields, you can add a script to "On Focus" and "On Blur" that would set a variable to the name of the field in question. When the focus event triggers, you'd know that field is active.
For annotations, you can use...
... to get an array of Annotation objects corresponding to all currently selected markup annotations.
I don't recall any other objects that can be detected when selected or deselected.