zoukankan      html  css  js  c++  java
  • c# 屏幕取词的方法(载)

    A、金山词霸组件法

    在金山词霸中2005中带了一个XdictGrb.dll,添加引用

    (为方便大家测试,本人安装了金山词霸2005,把其中的XdictGrb.dll给大家下载)

    废话不多说了,还是把源码放上

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Text;
    using System.Windows.Forms;
    using XDICTGRB;//金山词霸组件

    namespace WindowsApplication1
    {
        public partial class Form1 : Form,IXDictGrabSink
        {
            public Form1()
            {
                InitializeComponent();
            }
            private void Form1_Load(object sender, EventArgs e)
            {
                GrabProxy gp = new GrabProxy();
                gp.GrabInterval = 1;//指抓取时间间隔
                gp.GrabMode = XDictGrabModeEnum.XDictGrabMouse;//设定取词的属性
                gp.GrabEnabled = true;//是否取词的属性
                gp.AdviseGrab(this);
            }
            //接口的实现
            int IXDictGrabSink.QueryWord(string WordString, int lCursorX, int lCursorY, string SentenceString, ref int lLoc, ref int lStart)
            {
                this.textBox1.Text = SentenceString;//鼠标所在语句
                //this.textBox1.Text = SentenceString.Substring(lLoc + 1,1);//鼠标所在字符
                return 1;
            }
        }
    }

    B.Nhw32.dll法

    这个是C++写的一个组件

    nhw32.dll 主要引出两个函数:

    1. DWORD WINAPI BL_SetFlag32(UINT nFlag,
                                 HWND hNotifyWnd,
                                 int MouseX,
                                 int MouseY)
       功能:
     启动或停止取词。
       参数:
           nFlag
                  [输入] 指定下列值之一:
                  GETWORD_ENABLE: 开始取词。在重画被取单词区域前设置此标志。nhw32.dll是通过
                                  重画单词区域,截取TextOutA, TextOutW, ExtTextOutA,
                                  ExtTextOutW等Windows API函数的参数来取词的。
                  GETWORD_DISABLE: 停止取词。
           hNotifyWnd
                  [输入] 通知窗口句柄。当取到此时,向该通知窗口发送一登记消息:GWMSG_GETWORDOK。
           MouseX
      [输入] 指定取词点的X坐标。
           MouseY
                  [输入] 指定取词点的Y坐标。
        返回值:
           可忽略。
    2. DWORD WINAPI BL_GetText32(LPSTR lpszCurWord,
                                 int nBufferSize,
                                 LPRECT lpWordRect)
        功能:
     从内部缓冲区取出单词文本串。对英语文本,该函数最长取出一行内以空格为界的三个英文单词串,遇空格,非英文字母及除‘-’外的标点符号,则终止取词。对汉字文本,该函数最长取出一行汉字串,遇英语字母,标点符号等非汉语字符,则终止取词。该函数不能同时取出英语和汉语字符。
        参数:
           lpszCurWord
                  [输入] 目的缓冲区指针。
           nBufferSize
                  [输入] 目的缓冲区大小。
           lpWordRect
                  [输出] 指向 RECT 结构的指针。该结构定义了被取单词所在矩形区域。
        返回值:
            当前光标在全部词中的位置。

    此外,WinNT/2000版 nhw32.dll 还引出另两个函数:

    1. BOOL WINAPI SetNHW32()
        功能:
            Win NT/2000 环境下的初始化函数。一般在程序开始时,调用一次。
        参数:
            无。   
        返回值:
            如果成功 TRUE ,失败 FALSE 。

    2. BOOL WINAPI ResetNHW32()
        功能:
            Win NT/2000 环境下的去初始化函数。一般在程序结束时调用。
        参数:
            无。   
        返回值:
            如果成功 TRUE ,失败 FALSE 。

    载自:http://blog.csdn.net/jxncwzb/archive/2006/07/11/904807.aspx   
    感谢作者tag

  • 相关阅读:
    STL源代码学习--vector用法汇总
    [AngularJS] ng-ture-value & ng-false-value
    [Typescript] Installing Promise Type Definitions Using the lib Built-In Types
    [Typescript] Build Method decorators in Typescript
    [MST] Create Dynamic Types and use Type Composition to Extract Common Functionality
    [React] Refactor a Stateful List Component to a Functional Component with React PowerPlug
    [MST] Use Volatile State and Lifecycle Methods to Manage Private State
    [React] Use React Fragments to make your DOM tree cleaner
    [MST] Loading Data from the Server using lifecycle hook
    [Javascript] String Padding in Javascript using padStart and padEnd functions
  • 原文地址:https://www.cnblogs.com/tuyile006/p/582381.html
Copyright © 2011-2022 走看看