-
VB.net / IO / 获取鼠标键盘事件的钩子函数
VB.net / IO / 获取鼠标键盘事件的钩子函数
VB.net 中获取鼠标键盘的钩子函数。可以将代码粘贴至一个新建模块,然后在主程序中声明一个Hook,调用Hook的事件就可以得到鼠标键盘的返回值了。(原谅我把VB.net写出了Python风格…)
Imports System.Reflection
Imports System.ComponentModel
Imports System.Runtime.InteropServices
Imports System.Windows.Forms
Public Class SystemHook
Private Structure MouseHookStruct
Dim X,Y As Single, Hwnd, WHitTestCode, DwExtraInfo As Integer: End Structure
Private Structure MouseLLHookStruct
Dim X,Y As Single, MouseData, Flags, Time, DwExtraInfo As Integer: End Structure
Private Structure KeyboardHookStruct
Dim vkCode, ScanCode, Flags, Time, DwExtraInfo As Integer: End Structure
Public myeor As String
Private Declare Function SetWindowsHookExA Lib "user32" (ByVal idHook As Integer, ByVal lpfn As HookProc, ByVal hMod As IntPtr, ByVal dwThreadId As Integer) As Integer
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Int32, ByVal lpfn As HookProc, ByVal hMod As IntPtr, ByVal dwThreadId As Int32) As Int32
'SetWindowsHookEx(安装的钩子的类型,消息的处理函数,应用程序事例句柄,线程ID)
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal idHook As Int32) As Int32
Private Declare Function CallNextHookEx Lib "user32" (ByVal idHook As Int32, ByVal nCode As Int32, ByVal wParam As Int32, ByVal lParam As IntPtr) As Int32
Private Declare Function ToAscii Lib "user32" (ByVal uVirtKey As Int32, ByVal uScancode As Int32, ByVal lpdKeyState As Byte(), ByVal lpwTransKey As Byte(), ByVal fuState As Int32) As Int32
Private Declare Function GetKeyboardState Lib "user32" (ByVal pbKeyState As Byte()) As Int32
Private Declare Function GetKeyState Lib "user32" (ByVal vKey As Int32) As Short
Private Delegate Function HookProc(ByVal nCode As Int32, ByVal wParam As Int32, ByVal lParam As IntPtr) As Int32
Private Const WH_MOUSE_LL = 14, WH_KEYBOARD_LL = 13, WH_MOUSE = 7, WH_KEYBOARD = 2, WM_MOUSEMOVE = &H200, WM_LBUTTONDOWN = &H201, WM_RBUTTONDOWN = &H204, WM_MBUTTONDOWN = &H207, WM_LBUTTONUP = &H202, WM_RBUTTONUP = &H205, WM_MBUTTONUP = &H208, WM_LBUTTONDBLCLK = &H203, WM_RBUTTONDBLCLK = &H206, WM_MBUTTONDBLCLK = &H209, WM_MOUSEWHEEL = &H20A, WM_KEYDOWN = &H100, WM_KEYUP = &H101, WM_SYSKEYDOWN = &H104, WM_SYSKEYUP = &H105, VK_SHIFT As Byte =
栏目列表
最新更新
nodejs爬虫
Python正则表达式完全指南
爬取豆瓣Top250图书数据
shp 地图文件批量添加字段
爬虫小试牛刀(爬取学校通知公告)
【python基础】函数-初识函数
【python基础】函数-返回值
HTTP请求:requests模块基础使用必知必会
Python初学者友好丨详解参数传递类型
如何有效管理爬虫流量?
SQL SERVER中递归
2个场景实例讲解GaussDB(DWS)基表统计信息估
常用的 SQL Server 关键字及其含义
动手分析SQL Server中的事务中使用的锁
openGauss内核分析:SQL by pass & 经典执行
一招教你如何高效批量导入与更新数据
天天写SQL,这些神奇的特性你知道吗?
openGauss内核分析:执行计划生成
[IM002]Navicat ODBC驱动器管理器 未发现数据
初入Sql Server 之 存储过程的简单使用
这是目前我见过最好的跨域解决方案!
减少回流与重绘
减少回流与重绘
如何使用KrpanoToolJS在浏览器切图
performance.now() 与 Date.now() 对比
一款纯 JS 实现的轻量化图片编辑器
关于开发 VS Code 插件遇到的 workbench.scm.
前端设计模式——观察者模式
前端设计模式——中介者模式
创建型-原型模式