VB小程序 读取剪贴板后(复制),在可输入文本处双击 即可 粘贴 急求。
VB小程序读取剪贴板后(复制),在可输入文本处双击即可粘贴急求。在线等。。。双击粘贴要在浏览器文本框内可执行,谢谢了。。...
VB小程序 读取剪贴板后(复制),在可输入文本处双击 即可 粘贴 急求。在线等。。。双击粘贴要在浏览器文本框内可执行,谢谢了。。
展开
展开全部
'模块代码
Option Explicit
Public Declare Function SetWindowsHookEx Lib "User32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Public Declare Function UnhookWindowsHookEx Lib "User32" (ByVal hHook As Long) As Long
Public Declare Function CallNextHookEx Lib "User32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpvDest As Any, ByVal lpvSource As Long, ByVal cbCopy As Long)
Public Type MOUSEMSGS
X As Long
Y As Long
a As Long
b As Long
time As Long
End Type
Public Type POINTAPI
X As Long
Y As Long
End Type
Public Const WH_MOUSE_LL = 14
Public Const HC_ACTION = 0
Public MouseMsg As MOUSEMSGS
Public lHook(1) As Long
Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetFocus Lib "User32" () As Long
Private Declare Function GetDoubleClickTime Lib "User32" () As Long
Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Sub keybd_event Lib "User32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const VK_CONTROL = &H11
Private Const VK_V = &H56
Private Const KEYEVENTF_KEYUP = &H2
Public Sub AddHook()
lHook(0) = SetWindowsHookEx(WH_MOUSE_LL, AddressOf CallMouseHookProc, App.hInstance, 0)
End Sub
Public Sub DelHook()
UnhookWindowsHookEx lHook(0)
End Sub
'鼠标钩子
Public Function CallMouseHookProc(ByVal code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim pt As POINTAPI, DBLCLK As Long
Static DBtime As Long
DBLCLK = GetDoubleClickTime
If code = HC_ACTION Then
CopyMemory MouseMsg, lParam, LenB(MouseMsg)
If wParam = 512 Then DBtime = 0
If wParam = 514 Then DBtime = MouseMsg.time
If wParam = 513 And MouseMsg.time - DBtime <= DBLCLK Then '确定执行了 双击
If FindWindow("Internet Explorer_Server", vbNullString) = GetFocus() Then '再查找 是否在IE浏览器内
' Form1.Caption = Now & " 双击"
'发送 Ctrl + V 执行粘贴功能
Call keybd_event(VK_CONTROL, 0, 0, 0)
Call keybd_event(VK_V, 0, 0, 0)
Call keybd_event(VK_V, 0, KEYEVENTF_KEYUP, 0)
Call keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0)
Else
'Form1.Caption = Now & " 否"
End If
End If
End If
If code <> 0 Then CallMouseHookProc = CallNextHookEx(0, code, wParam, lParam)
End Function
'窗体代码
Option Explicit
Private Sub Form_Load()
AddHook
End Sub
Private Sub Form_Unload(Cancel As Integer)
DelHook
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询