That depends on a lot of things.
If the application supports AppleScripting, there may be a way to do it through AppleScript.
If not, the best you can do is check to see if “Edit->Copy” is enabled, but not all apps disable that when text isn’t selected.
What application are you working with?