Although JavaScript would be a much better choice for browsers, here's an example script that can do what you want.
SendMode, Input
~LButton UP::
clipTmp := ClipboardAll
Clipboard := ""
Send, ^c
ClipWait, 1
if(ErrorLevel) { ; No text selected
GoSub, RestoreClip
return
}
selectedText := Clipboard
GoSub, RestoreClip
TrayTip, Text selected!, % selectedText
return
RestoreClip:
Clipboard := clipTmp
clipTmp := ""
return
This is a very basic template that you'll have to adjust to your needs. For example, it won't work correctly when you're selecting a word by double clicking. Also, it "locks" the clipboard for one second after a click (no matter what), so that copying/pasting won't have effect within that time span. All these problems are bypassable, but I'll leave that up to you.
Moreover, be aware that this code relies on the target window to copy the selected text into the clipboard after CTRL + C has been sent to it; and this must happen faster than whatever timeout you pass to ClipWait
.