110,499
社区成员
发帖
与我相关
我的任务
分享
'将XdictGrb.dll放在system32下.运行regsvr32 XdictGrb.dll注册.
'新建工程,引用XdictGrb.dll.
'加三个Label到窗体.
Option Explicit
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const SWP_NOMOVE = &H2 '不移动窗体
Private Const SWP_NOSIZE = &H1 '不改变窗体尺寸
Private Const Flag = SWP_NOMOVE Or SWP_NOSIZE
Private Const HWND_TOPMOST = -1 '窗体总在最前面
Private Const HWND_NOTOPMOST = -2 '窗体不在最前面
Implements IXDictGrabSink
Private gp As GrabProxy
Dim f As Integer
Dim ls As String
Private Sub Form_Load()
ls = ""
f = FreeFile()
Open "c:\XDictGrb.txt" For Append As #f
Set gp = New GrabProxy
With gp
.GrabEnabled = True '是否有效
.GrabInterval = 5 '指定抓取时间间隔
.GrabMode = XDictGrabMouse '模式(鼠标是否加按键)
.AdviseGrab Me '接口指向自身
End With
SetWindowPos Form1.hwnd, HWND_TOPMOST, 0, 0, 0, 0, Flag
End Sub
Private Sub Label2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form1.Top = 600 - Form1.Top
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Form1.Top = 600 - Form1.Top
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set gp = Nothing
Close #f
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
' Label1.Caption = "当前坐标:" & "(" & lCursorX & "," & lCursorY & ")"
Label2.Caption = SentenceString
' Label3.Caption = "当前字符:" & Mid(SentenceString, lLoc + 1, 1000)
If ls <> SentenceString Then
ls = SentenceString
Print #f, ls
Clipboard.Clear
Clipboard.SetText ls
End If
If 0 <= lCursorX And lCursorX <= 559 Then
If 0 <= lCursorY And lCursorY <= 39 Then
Form1.Top = 600
End If
If 40 <= lCursorY And lCursorY <= 79 Then
Form1.Top = 0
End If
End If
End Function