如何获得的任何应用程序选定的文本到Windows窗体应用程序 [英] How to get selected text of any application into a windows form application

查看:96
本文介绍了如何获得的任何应用程序选定的文本到Windows窗体应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我要做的,

当用户通过双击选择任何正在运行的应用程序的任何字(文字)点击鼠标特别突出显示的文字应该插入这已经在运行一个Windows应用程序。

When user select any word(text) of any running application by double clicking the mouse particular highlighted word should be inserted into a windows application which is already running.

到目前为止,我已经实现了使用逻辑全局按键其中,用户必须触发<大骨节病> CRT + <大骨节病> C 键盘组合键选字成赢窗体应用程序复制。

So far I have implemented the logic using Global Keystroke where user has to trigger CRT+ C keyboard key combination to copy the selected word into win form application.

我想什么知道有没有什么办法让这些选定的文本到应用程序,而无需键盘任意键按键?

What i want to know is there any way to get those selected text into the application without having any button key press of the keyboard?

推荐答案

一些读取后,我已经找到了办法

after some reads I have found the way


  1. 使用这样的结果
    的http:// globalmousekeyhook.codeplex.com/

(可选)保存点击板

获取与USER32


获取与WindowFromPoint基于Windows CON光标位置USER32

Get the windows based con cursor position with WindowFromPoint from user32

[DllImport("user32.dll")]
public static extern IntPtr WindowFromPoint(Point lpPoint);

[DllImport("user32.dll")]
public static extern bool GetCursorPos(out Point lpPoint);

public static IntPtr GetWindowUnderCursor()
{
   Point ptCursor = new Point();

   if (!(PInvoke.GetCursorPos(out ptCursor)))
      return IntPtr.Zero;

   return WindowFromPoint(ptCursor);
}


  • 发送带有SendMessage函数形式的用户32见
    的复制命令使用的User32.dll SendMessage函数发送键使用ALT修改

    这篇关于如何获得的任何应用程序选定的文本到Windows窗体应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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