I would like a user to select text on a webpage, and to capture that text as a string automatically using the least number of user inputs as possible. Ideally, the user would simply select the desired text using ctrl-c, immediately after I would run the GetClipboardData() function and obtain that text. I have a solution that is close at this point, but it requires the user to hit enter:
import win32clipboard
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.CloseClipboard()
**string = input("select text and hit enter")**
win32clipboard.OpenClipboard()
win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
return string
Ideally, upon hitting ctrl-c, I would run GetClipboardData() without the user having to press enter. Any ideas?