There is generally no way on the Mac to know where the text selection is.
On a web page, you may be able to determine it and you might be able to map that to a coordinate in the page, which you might be able to map to a coordinate in a window which you could then click on. But I have no idea how to do any of this or even if it is possible.
You might be able to detect the selection with an image capture and clever image processing. But not natively in Keyboard Maestro (well, ok, you could scan through pixels, but it’d take a very very long time - Keyboard Maestro is not the tool for pixel processing!).