C#怎么实现金山词霸取词功能[Ctrl+Alt+F1]
当同时按下[Ctrl+Alt+F1]时,无论鼠标焦点在哪里,金山词霸都能捕捉到消息,请问
达人们,怎么实现?

解决方案 »

  1.   

    这个需要比较底层的操作,像系统挂钩、拦截API什么的,这些好像是用C#无法实现的
      

  2.   

    一个简单的办法是用金山词霸的dll,参看http://www.cnblogs.com/hakuci/articles/1131896.html
    我试了试,基本能用
      

  3.   

    直接拿金山词霸自带的DLL弄就可以了。我很久以前弄过一个玩玩。呵呵
      

  4.   

    在金山词霸中2005(或者2007)中带了一个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;
            }
        }
    }