How to get selected text from an active application, without using a clipboard

前端 未结 2 1693
一向
一向 2021-01-17 03:07

What am I doing:

My main intent is to enable user friendly text to speech for personal use on Win 7. Approach should work in Google Chrome, VS and Ecl

2条回答
  •  孤城傲影
    2021-01-17 03:32

    If to expand a little on what Bugfinder said, Microsoft provider a UI Automation Framework to solve problems like the one you mentioned:

    In particular you can use the TextSelectionChangedEvent of TextPattern:

    The problem with this solution is that it only works on supported operating systems and applications - and not all support this.

    Your clipboard solution is acceptable for applications that do not provide a good automation interface. But for many applications the UI Automation Framework will work well and will provide you with a far better solution.

提交回复
热议问题