找回密码
 加入
搜索
查看: 2270|回复: 0

[系统综合] au3能拦截WIN键却不能拦截CTRL键

[复制链接]
发表于 2010-6-14 12:22:59 | 显示全部楼层 |阅读模式
以下上P版的代码,能拦截WIN键。试过改键值,但不能拦截CTRL,ALT这些键。。是不是还要经过其它特殊处理?
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global $hHook, $hStub_KeyProc, $buf = "", $title = "", $title_1 = "", $keycode, $buffer = "", $nMsg

Local $hmod
$hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam")
$hmod = _WinAPI_GetModuleHandle(0)
$hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hStub_KeyProc), $hmod)
While 1
 Sleep(1)
WEnd

Func _KeyProc($nCode, $wParam, $lParam)
 Local $tKEYHOOKS, $wVKey
 $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)
 If $nCode < 0 Then
 Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam)
 EndIf
 $wVKey = DllStructGetData($tKEYHOOKS, "vkCode")
 If ($wVKey = 91) Then ;这里用的是asi2码
 If ($wParam = $WM_KEYDOWN) Then
 ToolTip("{win} was pressed.")
 Return 1
 ElseIf ($wParam = $WM_KEYUP) Then
 ToolTip("{win} was released.")
 EndIf
 EndIf
 Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam)
EndFunc ;==>_KeyProc

Func _exit()
 _WinAPI_UnhookWindowsHookEx($hHook)
 DllCallbackFree($hStub_KeyProc)
 Exit
EndFunc ;==>_exit
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-29 17:39 , Processed in 0.071976 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表