0

I tried to find an example for that, but I failed. Can someone tell me what method to use to get the current text selection. I know it's possible in .NET 4.. but I want to make it using winapi so I can use it in .NET 2.

EDIT: This is only possible with UI Autonation.

blez
  • 4,939
  • 5
  • 50
  • 82

2 Answers2

2

The UI automation TextPattern allows you to do this (it's more modern than IAccessible). Check out my answer to this SO question: How to get the word under the cursor in Windows?

Community
  • 1
  • 1
Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
  • UI Automation is part of .NET 4. I specified that I want a WINAPI or .NET 2 soluton. And btw, the post you gave me is mine. – blez Feb 26 '11 at 18:14
  • @blez - oops sorry. didn't catch you were the same guy :-). UI automation is actually available starting with .NET 3.0 – Simon Mourier Feb 26 '11 at 18:23
  • I actually hoped to see a native way to do it. Cause I'm strictly using .NET 2. – blez Feb 26 '11 at 18:38
0

You can use IAccessilble from the .NET Framework. That likely will not be enough however. But using the information provided from IAccessible, you can then choose how to communicate with the text object. Investigate the Text Services Framework on how to extract text from an application that supports TSF.