Capture Highlighted Text from any window using C#

后端 未结 1 1767
鱼传尺愫
鱼传尺愫 2021-01-13 05:07

How to read the highlighted/Selected Text from any window using c#.

i tried 2 approaches.

  1. Send \"^c\" whenever user selects some thing. But in this cas
相关标签:
1条回答
  • 2021-01-13 06:03

    That's because both Firefox and Visual Studio don't use the built-in Win32 controls for displaying/editing text.

    It is not possible in general to be able to get the value of "any" selected text, because of the fact that programs can re-implement their own version of the Win32 controls any way they see fit, and your program cannot possibly expect to work with all of them.

    However, you can use the UI Automation APIs which will allow you to interact with the majority of 3rd-party controls (at least, all the good ones - such as Visual Studio and Firefox - will likely work with the UI Automation APIs since it's a requirement for accessibility)

    0 讨论(0)
提交回复
热议问题