Partager via


What Isn’t TSF good for?

Well, for one thing, it’s not that great for grabbing the current selection in the foreground application. 

There are several problems here:

1) You have to get your text service loaded into the target application. This can be slow.

2) Once your text service is loaded, you can only really work with TSF-enabled applications, which, sadly, are few and far between.

What do I recommend?  There aren’t any really good solutions.  MSAA doesn’t have good text support.  UI Automation doesn’t have good native support (although it works very nicely in managed applications, and has good text support).  You can use the clipboard, but users tend to be somewhat attached to their clipboard contents.  (Saving & restoring the clipboard is possible, but can be tricky – application vendors will often register private clipboard formats that contain pointers which get invalidated when the clipboard changes.  When you put the clipboard back, you will crash the application.  Most vendors don’t do that, but it’s something you should be aware of.)

If you do decide to use the clipboard, then this guy has implemented a pretty fancy clipboard manager, and has a good discussion of various traps & pitfalls with the clipboard.