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")
if wparam = wm_mbuttondown then '把中鍵改為左鍵
mouse_event mouseeventf_leftdown, 0, 0, 0, 0
callmousehookproc = 1
end if
if wparam = wm_mbuttonup then
mouse_event mouseeventf_leftup, 0, 0, 0, 0
callmousehookproc = 1
end if
end if
if code <> 0 then
callmousehookproc = callnexthookex(0, code, wparam, lparam)
end if
end function
'鍵盤鉤子
public function callkeyhookproc(byval code as long, byval wparam as long, byval lparam as long) as long
dim lkey as long
dim strkeyname as string * 255
dim strlen as long
if code = hc_action then
copymemory keymsg, lparam, lenb(keymsg)
select case wparam
case wm_syskeydown, wm_keydown, wm_syskeyup, wm_keyup:
lkey = keymsg.skey and &hff '掃瞄碼
lkey = lkey * 65536
strlen = getkeynametext(lkey, strkeyname, 250)
form1.txtmsg(0).text = "鍵名:" + left(strkeyname, strlen) + " 偽程式碼:" + format(keymsg.vkey and &hff, "0") + " 掃瞄碼:" + format(lkey / 65536, "0")
form1.txthwnd(0) = ""
if (getkeystate(vbkeycontrol) and &h8000) then
form1.txthwnd(0) = form1.txthwnd(0) + "ctrl "
end if
if (keymsg.flag and alt_down) <> 0 then
form1.txthwnd(0) = form1.txthwnd(0) + "alt "
end if
if (getkeystate(vbkeyshift) and &h8000) then
form1.txthwnd(0) = form1.txthwnd(0) + "shift"
end if
'keymsg.vkey and &hff 偽程式碼
'lkey / 65536 掃瞄碼
if (keymsg.vkey and &hff) = vbkeyy then '把y鍵替換為n
if wparam = wm_syskeydown or wparam = wm_keydown then
keybd_event vbkeyn, 0, 0, 0
end if
callkeyhookproc = 1 '遮蔽按鍵
end if
end select
end if
if code <> 0 then
callkeyhookproc = callnexthookex(0, code, wparam, lparam)
end if
end function
VB 用全域性鉤子,記錄滑鼠點選次數
首先用建立乙個標準exe程式 把窗體名稱,設定為frmmain 在窗體上建立一組文字框陣列,名稱為txtmsg txtmsg 0 顯示滑鼠左鍵按下的次數 txtmsg 1 顯示滑鼠中鍵按下的次數 txtmsg 2 顯示滑鼠右鍵按下的次數 txtmsg 3 顯示滑鼠按下的總次數 首先建立乙個modul...
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 ...
c 全域性鍵盤鉤子
using system using system.collections.generic using system.text using system.windows.forms using system.runtime.interopservices using system.diagnosti...