How can AS tell if my mouse click is in a text field or on a file?

I just single clicked somewhere, (button-1 down and up), and now my next AS action depends on what I clicked on. If the click is in a text field (any app) then I want to Copy whatever a Dbl-click selects and exit, and if it’s on a file then Copy the name of the file and exit. If the click is somewhere else then ignore it.

I would greatly appreciate it if someone could make that happen.

Let me narrow it down a little. I need to check the object just clicked on to see what it is (could be nothing). I can’t check first to see if it’s text because to that I’d have to double click it and this wouldn’t be good if it was actually a file. So I have to check first if it’s a file, and really that’s my only problem. If I can get past that then I’m away. So, to narrow the question down, how can AS test to see if whatever the mouse just clicked on is a file?