using system;
using system.collections.generic;
using system.text;
using system.windows.forms;
using system.runtime.interopservices;
using system.diagnostics;
namespace webclick_tool
//委託
public delegate int hookproc(int ncode, int wparam, intptr lparam);
static int hhook = 0;
public const int wh_keyboard_ll = 13;
//lowlevel鍵盤截獲,如果是wh_keyboard=2,並不能對系統鍵盤擷取,acrobat reader會在你擷取之前獲得鍵盤。
static hookproc keyboardhookprocedure;
//設定鉤子
[dllimport("user32.dll")]
public static extern int setwindowshookex(int idhook, hookproc lpfn, intptr hinstance, int threadid);
[dllimport("user32.dll", charset = charset.auto, callingconvention = callingconvention.stdcall)]
//抽掉鉤子
public static extern bool unhookwindowshookex(int idhook);
[dllimport("user32.dll")]
//呼叫下乙個鉤子
public static extern int callnexthookex(int idhook, int ncode, int wparam, intptr lparam);
[dllimport("kernel32.dll")]
public static extern int getcurrentthreadid();
[dllimport("kernel32.dll")]
public static extern intptr getmodulehandle(string name);
public static void hook_start()}}
/// /// 取消鉤子事件
///
public static void hook_clear()
}public static int keyboardhookproc(int ncode, int wparam, intptr lparam)
else if (kbh.flags == 128)
return 1;}}
return callnexthookex(hhook, ncode, wparam, lparam);}}
}
VC全域性鍵盤鉤子
hodll.h main header file for the hodll dll if defined afx hodll h b2a458dc 71e2 47d5 9ea0 58385d558643 included define afx hodll h b2a458dc 71e2 47d5 ...
HOOK使用 全域性鍵盤鉤子
define win32 winnt 0x0500 設定系統版本,可以使用底層鍵盤鉤子 define wm my shorts wm user 105 include windows.h 全域性變數 lpword g lpdwvirtualkey null keycode 陣列的指標 int g n...
VB 全域性鍵盤 滑鼠鉤子
if code hc action then copymemory mousemsg,lparam,lenb mousemsg form1.txtmsg 1 text x str mousemsg.x y str mousemsg.y form1.txthwnd 1 format wparam,0 ...