从单独的程序中获取所选文本 [英] Getting selected text from a separate program

查看:68
本文介绍了从单独的程序中获取所选文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将注意力集中在记事本应用程序上并向其发送ctrl + c?

编辑:我实际上正在为Rss添加一个加载项在feed agregator应用程序中,我创建了一个小尺寸的Form,将formBorderStyle设置为none,将TopMost设置为true,并添加了一个按钮,使其看起来像一个Add-on。我需要的是:当用户从另一个应用程序(Rss Aregator)的导航栏中选择Url的文本并单击我的小表单的按钮时,必须将highlited链接的字符串文本复制到剪贴板。似乎这对我的问题来说不是一个简单的解决方案,邀请用户复制所选文本必须更方便...是否有其他方法可以做到这一点或任何计算机语言或技术具有很强的实现能力我正在尝试做什么?

How can I set focus on Notepad application and send ctrl+c to it?
EDIT : I''m actually working on an add-on for a Rss feed agregator application , I created a Form with small size, set the formBorderStyle to none and TopMost to true, and added a button so that looks like an Add-on. All I need is : when the user select the text of a Url from the navigation bar of the other application(Rss Aregator) and click on the button of my little form, the string text of the highlited link must be copyed to the clipboard. It seems that it''s not an easy solution for my problem, inviting the user to copy the selected text must be more convenient... Is there another way to do that or any computer language or technology that haves strong ability to realilze easily what I''m trying to do?

推荐答案

1)将注意力集中在记事本实例上



http://stackoverflow.com/questions/1922707/setting-external-application-focus [ ^ ]



2)使用SendKeys向应用程序发送Ctrl + C将所选文本复制到剪贴板



http://msdn.microsoft.com/en-us/library/system.windows.forms .sendkeys.aspx [ ^ ]



3)使用Clipboard.GetText从剪贴板中检索文本



http://msdn.microsoft.com/en-us/library/kz40084e.aspx [ ^ ]
1) Set focus on the notepad instance

http://stackoverflow.com/questions/1922707/setting-external-application-focus[^]

2) Use SendKeys to send "Ctrl + C" to the application to copy the selected text to the clipboard

http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx[^]

3) Retrieve the text from the clipboard using Clipboard.GetText

http://msdn.microsoft.com/en-us/library/kz40084e.aspx[^]


这篇关于从单独的程序中获取所选文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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