在活动窗口中获取所选项目 [英] Getting selected item in active window

查看:52
本文介绍了在活动窗口中获取所选项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#开发适用于剪贴板的应用程序,他想知道是否有可能获取用户在当前窗口中选择的内容,而不管它是在哪个窗口中(例如FireFox,记事本等)。

I am using C# to develop an application that works with the clipboard, an was wondering if its possible to get the contents of what the user has selected in the current window, no matter what window it is (e.g. could be FireFox, notepad, etc.).

推荐答案

我不确定您是否能够获得针对这个问题。看看这个链接;

I'm not sure if you're going to be able to get a general solution for this problem. Take a look at this link;

http://www.eggheadcafe.com/software/aspnet/33899121/get-selected-text-of-active-window-.aspx

这篇文章的作者报告说,他们的解决方案可在记事本中使用,但不适用于Wordpad或Word。我对此领域了解不多,但是我想这意味着可以通过多种方式来实现文本选择-即使在Windows中也是如此。

The author of this post reports that their solution works in Notepad, but not in Wordpad or Word. I don't know much about this area, but I would guess that this means there are various means through which text selection is implemented - even within Windows.

我认为还扩展到Control-C,而不仅仅是文本选择。我相信根据使用它的上下文,可以使用不同的方式来处理复制命令。

I think this also extends to Control-C, not just text selection. I believe that there are different ways of handling the copy command depending on the context in which it's used.

例如,如果在对话框中按Control-C Windows,它将复制文本而无需您手动选择。

For example, if you press Control-C on a dialog box in Windows, it will copy the text without you have to select it manually.

希望上面的链接对您有用。

Hopefully the link above is of some use to you. This seems like an interesting problem to overcome.

编辑:

>发言太早-刚刚找到此链接;

http://social.msdn.microsoft.com/Forums/en/winformsapplications/thread/1dc356e6-9441-44de-9eda-247003fa6ef5

看起来这正是您想要的-希望它能起作用。

这篇关于在活动窗口中获取所选项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆