Option Explicit Public Event MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) Public Event MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) Public Event MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) Public Event KeyDown(KeyCode As Integer, Shift As Integer) Public Event KeyUp(KeyCode As Integer, Shift As Integer) Public Event SystemKeyDown(KeyCode As Integer) Public Event SystemKeyUp(KeyCode As Integer) Private 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 Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long Private Declare Function GetAsyncKeyState% Lib "user32" (ByVal vKey As Long) Private Const WM_KEYDOWN = &H100 Private Const WM_KEYUP = &H101 Private Const WM_MOUSEMOVE = &H200 Private Const WM_LBUTTONDOWN = &H201 Private Const WM_LBUTTONUP = &H202 Private Const WM_LBUTTONDBLCLK = &H203 Private Const WM_RBUTTONDOWN = &H204 Private Const WM_RBUTTONUP = &H205 Private Const WM_RBUTTONDBLCLK = &H206 Private Const WM_MBUTTONDOWN = &H207 Private Const WM_MBUTTONUP = &H208 Private Const WM_MBUTTONDBLCLK = &H209 Private Const WM_MOUSEWHEEL = &H20A Private Const WM_SYSTEMKEYDOWN = &H104 Private Const WM_SYSTEMKEYUP = &H105 Private Const WH_JOURNALRECORD = 0 Private Const WH_GETMESSAGE = 3 Private Type EVENTMSG wMsg As Long lParamLow As Long lParamHigh As Long msgTime As Long hWndMsg As Long End Type Dim EMSG As EVENTMSG Public Function SetHook() As Boolean If hJournalHook = 0 Then hJournalHook = SetWindowsHookEx(WH_JOURNALRECORD, AddressOf JournalRecordProc, App.hInstance, 0) If hAppHook = 0 Then hAppHook = SetWindowsHookEx(WH_GETMESSAGE, AddressOf AppHookProc, App.hInstance, App.ThreadID) SetHook = True End Function Public Sub RemoveHook() UnhookWindowsHookEx hAppHook UnhookWindowsHookEx hJournalHook hAppHook = 0 hJournalHook = 0 End Sub Private Sub Class_Initialize() SHptr = ObjPtr(Me) End Sub Private Sub Class_Terminate() If hJournalHook Or hAppHook Then RemoveHook End Sub Friend Function FireEvent(ByVal lParam As Long) Dim i%, j%, k% Dim s As String If lParam = WM_CANCELJOURNAL Then hJournalHook = 0 SetHook Exit Function End If CopyMemory EMSG, ByVal lParam, Len(EMSG) Select Case EMSG.wMsg Case WM_KEYDOWN j = 0 If GetAsyncKeyState(vbKeyShift) Then j = (j Or 1) 'fixed by JJ If GetAsyncKeyState(vbKeyControl) Then j = (j Or 2) 'fixed by JJ If GetAsyncKeyState(vbKeyMenu) Then j = (j Or 4) 'fixed by JJ s = Hex(EMSG.lParamLow) k = (EMSG.lParamLow And &HFF) RaiseEvent KeyDown(k, j) s = Left$(s, 2) & Right$("00" & Hex(k), 2) 'fixed by JJ EMSG.lParamLow = CLng("&h" & s) CopyMemory ByVal lParam, EMSG, Len(EMSG) Case WM_KEYUP j = 0 'fixed by JJ If GetAsyncKeyState(vbKeyShift) Then j = (j Or 1) 'fixed by JJ If GetAsyncKeyState(vbKeyControl) Then j = (j Or 2) 'fixed by JJ If GetAsyncKeyState(vbKeyMenu) Then j = (j Or 4) 'fixed by JJ s = Hex(EMSG.lParamLow) k = (EMSG.lParamLow And &HFF) RaiseEvent KeyUp(k, j) s = Left$(s, 2) & Right$("00" & Hex(k), 2) 'fixed by JJ EMSG.lParamLow = CLng("&h" & s) CopyMemory ByVal lParam, EMSG, Len(EMSG) Case WM_MOUSEMOVE i = 0 'fixed by JJ If GetAsyncKeyState(vbKeyLButton) Then i = (i Or 1) 'fixed by JJ If GetAsyncKeyState(vbKeyRButton) Then i = (i Or 2) 'fixed by JJ If GetAsyncKeyState(vbKeyMButton) Then i = (i Or 4) 'fixed by JJ j = 0 'fixed by JJ If GetAsyncKeyState(vbKeyShift) Then j = (j Or 1) 'fixed by JJ If GetAsyncKeyState(vbKeyControl) Then j = (j Or 2) 'fixed by JJ If GetAsyncKeyState(vbKeyMenu) Then j = (j Or 4) 'fixed by JJ RaiseEvent MouseMove(i, j, CSng(EMSG.lParamLow), CSng(EMSG.lParamHigh)) Case WM_LBUTTONDOWN, WM_RBUTTONDOWN, WM_MBUTTONDOWN i = 0 'fixed by JJ If GetAsyncKeyState(vbKeyShift) Then i = (i Or 1) 'fixed by JJ If GetAsyncKeyState(vbKeyControl) Then i = (i Or 2) 'fixed by JJ If GetAsyncKeyState(vbKeyMenu) Then i = (i Or 4) 'fixed by JJ RaiseEvent MouseDown(2 ^ ((EMSG.wMsg - 513) / 3), i, CSng(EMSG.lParamLow), CSng(EMSG.lParamHigh)) Case WM_LBUTTONUP, WM_RBUTTONUP, WM_MBUTTONUP i = 0 'fixed by JJ If GetAsyncKeyState(vbKeyShift) Then i = (i Or 1) 'fixed by JJ If GetAsyncKeyState(vbKeyControl) Then i = (i Or 2) 'fixed by JJ If GetAsyncKeyState(vbKeyMenu) Then i = (i Or 4) 'fixed by JJ RaiseEvent MouseUp(2 ^ ((EMSG.wMsg - 514) / 3), i, CSng(EMSG.lParamLow), CSng(EMSG.lParamHigh)) Case WM_SYSTEMKEYDOWN s = Hex(EMSG.lParamLow) k = (EMSG.lParamLow And &HFF) If k <> vbKeyMenu Then RaiseEvent SystemKeyDown(k) s = Left$(s, 2) & Right$("00" & Hex(k), 2) 'fixed by JJ EMSG.lParamLow = CLng("&h" & s) CopyMemory ByVal lParam, EMSG, Len(EMSG) Case WM_SYSTEMKEYUP s = Hex(EMSG.lParamLow) k = (EMSG.lParamLow And &HFF) If k <> vbKeyMenu Then RaiseEvent SystemKeyUp(k) s = Left$(s, 2) & Right$("00" & Hex(k), 2) 'fixed by JJ EMSG.lParamLow = CLng("&h" & s) CopyMemory ByVal lParam, EMSG, Len(EMSG) Case Else End Select End Function Public Property Get HookState() As Boolean If hAppHook = 0 Then HookState = False Else HookState = True End If End Property
分享到:
相关推荐
【VB的PDFPrinter.cls打印模块】是Visual Basic (VB)应用程序中用于生成PDF文档的关键组件。这个模块允许开发者集成PDF打印功能,使用户能够将应用程序内的数据或内容直接转化为高质量的PDF格式,便于保存、分享和...
数学建模美赛的论文latex模板
WinEdt在运行爱思维尔模板时候需要的文件
《MDPI_template_relay_wireless_theory:基于最优停止理论的中继选择代码解析》 在无线通信领域,中继技术是一种重要的传输策略,能够增强信号覆盖范围、提高通信质量。本文将深入探讨一个利用最优停止理论进行...
它由五个核心文件组成:`ctexart.cls`, `ctexrep.cls`, `ctexbook.cls`, `ctex.sty`, 和 `ctexcap.sty`。这些文件共同工作,为用户在 LaTeX 中创建中文文档提供了便捷和定制化的环境。 1. **ctex.sty** 是基础组件...
《clsFTP.cls:提升FTP操作效率的利器》 在IT领域,文件传输是日常工作中不可或缺的一部分,特别是对于程序员和系统管理员来说。FTP(File Transfer Protocol)作为一种基础的文件传输协议,广泛应用于各种场景,...
Application.cls box.dat clsEdge.cls clsEntity.cls clsFace.cls clsFile.cls clsFileHistory.cls clsFrame.cls clsGroup.cls clsJoint.cls clsJointRow.cls clsLayer.cls clsLightStyle.cls ...
标题中的“高度优化的DS1加密模块.zip_DS1啥模块_clsDS1.cls_ds1”指出,这个压缩包包含了一个名为“DS1”的加密模块,它可能是经过精心优化以提高性能和安全性。描述中的“高度优化的DS1加密模块”进一步强调了这个...
在LaTeX编辑器中(如TeXstudio或Overleaf),新建一个项目,并将`IEEEtran.cls`文件导入到项目中。 2. **基本结构**: `IEEEtran`模板定义了论文的基本结构,包括封面、摘要、关键词、正文、参考文献等部分。在`....
summary.cls-1.php
总结来说,要实现Java控制DOS清屏功能,你需要将提供的CLS.class和cls.dll文件与你的Java项目一起放置,并调用`CLS.CLS()`方法。这个过程可能涉及到JNI或通过执行外部进程,具体取决于CLS类和cls.dll的具体实现。...
这里,我们关注的是一个名为"transform.cls"的文件,它是用Visual Basic for Applications (VBA)编写的,用于实现地理变换,特别是七参数转换。这个功能允许用户在不同坐标系之间进行精确的数据转换。 七参数转换是...
Upnp协议模块 - UpnpClass.Cls,P2P路由器端口映射模块,代码写了两个晚上 查了N多资料 各位手下留情 留个版权吧,寻找Upnp设备,此函数使用的UDP多播进行消息传递。所以收发函数和 Tcp的不同,VB用Winsock多播用了 ...
【ControlsAnchor.cls V1.2 终结版】是一个针对Windows Forms开发的控件定位类库,由开发者在CSDN博客上分享。这个库的主要目的是帮助程序员更方便地管理和定位用户界面(UI)中的控件,特别是当窗口大小变化时,...
其中,“cutf8.cls”很可能是一个自定义的类模块,用于实现UTF-8编码和解码功能。类模块是一种封装代码的方式,它将相关的方法和属性组合在一起,方便在多个地方重复使用。用户可以创建一个CUTF8对象实例,然后调用...
《中文书籍、学位论文模板》是一个专为撰写中文书籍和学位论文设计的LaTeX模板,其核心是基于`\texttt{cctbook.cls}`类文件。这个模板以其简洁、高效和易用性著称,旨在帮助作者快速地构建出符合规范的高质量文档。 ...
标题 "ClsINI.cls_visualbasic_" 暗示我们即将探讨的是一个使用Visual Basic(VB)编写的类模块,专门用于处理INI配置文件的读取操作。INI文件是一种常见的存储应用程序设置和配置信息的简单文本格式。这个类模块...
latex模板cumcmthesis.cls包
本文将深入探讨一个特定的控件实现——`UpDown`控件,并介绍如何使用`CUpDown.cls`类来替代传统的ActiveX控件,如Microsoft Windows Common Controls-2 6.0中的Updown控件。 `UpDown`控件,也被称为增量/递减控件或...