您的位置:程序门 -> vb ->



关于键盘钩子的问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


关于键盘钩子的问题
发表于:2007-04-15 17:01:37 楼主
我想捕捉系统的ctrl+q消息,但我不能解析出ctrl对应的键q,代码如下

public   type   eventmsg
    vkey   as   long
    skey   as   long
    flag   as   long
    time   as   long
  end   type
public   mymsg     as   eventmsg
'钩子函数
public   function   mykbhook(byval   ncode   as   long,   byval   wparam   as   long,   byval   lparam   as   long)   as   long
dim   intshift   as   long
if   ncode   > =   0   then
        intshift   =   0
        mykbhook   =   0  
        if   wparam   =   wm_keydown   then
                '判断出ctrl键是否使用
                if   getasynckeystate(vbkeycontrol)   then   intshift   =   (intshift   or   2)
                copymemory   mymsg,   byval   lparam,   len(mymsg)
                if   mymsg.vkey   =   76   and   (intshift   =   2)   then
                        mykbhook   =   1
                end   if
        end   if
end   if
call   callnexthookex(hhook,   ncode,   wparam,   lparam)   '将消息传给下一个钩子
end   function
'挂接钩子
hhook   =   setwindowshookex(wh_keyboard_ll,   addressof   mykbhook2,   app.hinstance,   0)
但在按下ctrl+q之后,捕捉解析的消息mymsg.vkey   =162   mymsg.skey   =   29   我看有些介绍说应该为mymsg.vkey   =   76   ,请各位高手帮忙谢谢!
发表于:2007-04-15 17:03:151楼 得分:0
上面的值写错了应该位   q的ascii值!
发表于:2007-04-15 20:03:572楼 得分:0
.....................................
发表于:2007-04-16 10:08:423楼 得分:0
问题已经解决,谢谢各位!
发表于:2007-04-17 11:44:294楼 得分:0
...............和我一样bèn
发表于:2007-04-24 15:24:215楼 得分:0
我也在看hook用的也是一样的,好象得到的值不是ascii码吧,应该是键的键值吧?????

发表于:2007-04-24 16:57:566楼 得分:0
问题已经解决,谢谢各位!
???????????
可不可以说明是什么问题呢?
真后悔看到这个贴子。
发表于:2007-04-27 18:21:517楼 得分:0
mymsg.vkey   需要用mapvirtualkey函数处理一下才能取得真正的q的ascii值,


快速检索

最新资讯
热门点击