Use Kingsoft's word Acquisition Function

Source: Internet
Author: User
Tags constant definition

Use Kingsoft's word acquisition function (xdictgrb. dll)
Recently, I want to use a function similar to Kingsoft's word acquisition function, but I found some information on the Internet, which is complicated. Since Kingsoft has been implemented, why don't we borrow it? (Part of the software released without the approval of Kingsoft shall be infringing. Please note !)
This article references the following articles:
Screen implementation using Kingsoft Mac Components
1 Interface

1.1 grabproxy get the word proxy object

Function advisegrab (xdictgrabsink as ixdictgrabsink) as long
Broadcast an xdictgrabsink (if you want to implement the word fetch function, you need to implement this interface by yourself. The specific method will be introduced later. (Visual Basic example, similar to other languages) interface, when you need to take the word, it will call the queryword method of xdictgrabsink, You can implement the functions you need here.
Property grabenabled as Boolean
Whether to take the word attribute
Property grabmode as xdictgrabmodeenum
Set the attribute of the word, which will be described later in the definition of xdictgrabflagenum.
Property grabflag as xdictgrabflagenum
Set word keys, such as whether to combine CTRL or shift.
Property grabsystemcp as long
This attribute is not clear yet.
Sub grabword (lcursorx as long, lcursory as long)
Take the words X and Y coordinates. It is estimated that the words are screen coordinates.
Sub unadvisegrab (lcookie as long)
Cancel the broadcast of the xdictgrabsink interface.
Property xdictgrabplugins as ipluginscollection
Returns an ipluginscollection.
1.2 ipluginscollection collection object
A plug-in framework is implemented, but if you only want to implement the screen word retrieval function, you can also temporarily disable the plug-in function.
1.3 ixdictgrabplugin plug-in Interface
1.4 The ixdictgrabrot interface name does not quite understand what it means. It is used for registration and anti-Registration of plug-ins.
1.5 ixdictgrabsink: the interface to be implemented by yourself. For more information, see the following example.
Function queryword (wordstring as string, lcursorx as long, lcursory as long, sentencestring as string, lloc as long, lstart as long) as long
You can implement your own functions in this method. The wordstring parameter should be the word where the mouse is located, the lcursorx is the current X coordinate of the mouse, and the lcursory is the current y coordinate of the mouse, sentencestring is the entire sentence where the mouse is located, lloc is the position of the word where the mouse is located in the entire sentence, and the subscript starts from 0. Lstart is not clear at the moment.
2. Constant Definition
2.1 xdictgrabflagenum
Const xdictgrabdisablebutton = 4
Remove text from the button
Const xdictgrabdisablecaption = 8
Text not in the title bar
Const xdictgrabdisablemenu = 2
Do not retrieve text from the menu
Const xdictgrabonlyenglish = 1
English only
The preceding constants can be combined with (and.
2.2 xdictgrabmodeenum
Const xdictgrabmouse = 1
Use the mouse to retrieve words
Const xdictgrabmousewithctrl = 3
Use the mouse and press Ctrl to get the word
Const xdictgrabmousewithmiddlebutton = 4
Use the mouse and the middle mouse to extract words
Const xdictgrabmousewithshift = 2
Use the mouse and shift to get words
2.3 Enum xdictgrabpluginpriorityenum set the priority of the plug-in
Const xdictgrabprioritychief = 4
Const xdictgrabprioritygeneral = 1
Const xdictgrabprioritynormal = 2
Const xdictgrabpriorityspecial = 3
3 sample code (Implemented Using VB6)
3.1 create a project and add reference to xdictgrb 1.0 Type Library (xdictgrb. dll) in refernce. When adding a reference, I encountered some errors, indicating that the reference cannot be added. This may be because of the Kingsoft node running problem. My solution is to copy the dynamic library to another location, and then run regsvr32 to register it.
3.2 Add the following code to form form1, where the queryword method writes some results of the word to the immediate common mouth of VB.
'Define a class
Dim GP as grabproxy
'Inherit
Implements ixdictgrabsink
Dim dwcookie as long

Private sub form_load ()
'Create a new instance
Set Gp = new grabproxy
'There are some related attributes in GP

'Example: grabinterval grabmode grabenabled grabflag
'Specifies the capture interval, mode (whether to add a button to the mouse), valid, and flag (not to capture Chinese characters, titles, menus, or buttons)
GP. grabinterval = 0.5
GP. grabmode = xdictgrabmousewithctrl
GP. grabenabled = true
'After setting the property, point the interface to itself
Dwcookie = GP. advisegrab (me)
End sub

Private function ixdictgrabsink_queryword (byval wordstring as string, byval lcursorx as long, byval lcursory as long, byval sentencestring as string, lloc as long, lstart as long) as long
Debug. Print "wordstring:" + wordstring + CHR (10) + CHR (13 )_
; "Sentencestring:" + sentencestring + CHR (10) + CHR (13 )_
; "Lcursorx:" + STR (lcursorx) + CHR (10) + CHR (13 )_
; "Lcursory:" + STR (lcursory) + CHR (10) + CHR (13 )_
; "Lloc:" + STR (lloc) + CHR (10) + CHR (13 )_
; "Lstart:" + STR (lstart) + CHR (10) + CHR (13 )_
+ "============================================ ===== "+ CHR (10) + CHR (13)
'The return value of this function is not clear yet
Queryword = 1
End Function

Private sub form_unload (cancel as integer)
GP. unadvisegrab dwcookie
End sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.