0

I have found several answers on how to copy a text from any application in windows and c# similar question

The problem with this answers approach is that it uses the clipboard without the user knowing. Backing up and restoring the clipboard is not a recommended pratice as pointed out in this answer: clipboard restore problem

So my questions is if there is an alternative to get the selected text from any application without sending ctrl-c or is there a safe way to backup and restore the clipboard.

Rand Random
  • 7,300
  • 10
  • 40
  • 88
Johannes
  • 441
  • 5
  • 15
  • You can try using accessibility APIs. – SLaks Feb 16 '18 at 16:06
  • You can use the Win32 APIs to get the current location of the cursor, locate the window underneath it and query the hWnd to determine the control with selected text and extract it. Fairly convoluted though. Easier to back up the current contents of the clipboard, use the clipboard to capture the text and restore the clipboard afterwards. – DiskJunky Feb 16 '18 at 16:07

0 Answers0