求救:急!急!急!急!急!急!拦截按下ctrl和alt之间的win键的消息(0分)

大梦

Unregistered / Unconfirmed
GUEST, unregistred user!
有win键按下时,弹出自己的窗口,屏蔽“开始菜单”。
 
试试registerhotkey看,有没有效果。。。。。
 
有效果但它比你优先,
我的做法是:找到开始菜单的句柄并把它释放了,然后注册两个win热键(一个左win一个右win)
 
To: Snappy,能不能详细给我讲一下。或发些资料给我。谢谢。

deitiqpl@163.com

deit@0335.net
 
能够触发,但屏蔽不了开始菜单。
 
用键盘低层Hook吧,能够屏蔽win键。。
代码如下:
function LowLevelKeyboardProc(nCode:integer;WParam:WPARAM;LParam:LPARAM):LRESULT;stdcall;
type
KBDLLHOOKSTRUCT=record
vkCode:DWORD;
scanCode:DWORD;
flags:DWORD;
time:DWord;
dwExtraInfo:dword;
end;
var
fFlag:BOOL;
p:^KBDLLHOOKSTRUCT;
begin
result:=0;
fFlag := false;
p:=Pointer(LPARAM);
if (ncode=HC_ACTION) then
begin
case wparam of
WM_KEYDOWN,
WM_SYSKEYDOWN,
WM_KEYUP,
WM_SYSKEYUP:
fFlag :=(p.vkCode = VK_Lwin) or (p.vkCode = VK_Rwin)or (p.vkCode = VK_apps);
end;
end;
if fFlag = true then
Result:=1;
if ncode <> 0 then
Result := CallNextHookEX(0,ncode,wparam,lparam);
end;

procedure TForm1.Button1Click(Sender: TObject);
const
WH_KEYBOARD_LL=13;
begin
setwindowshookexw(WH_KEYBOARD_LL,LowlevelKeyboardproc,hinstance,0);
end;
 
不会吧,没分的。亏了。
 
T0:yeath
首先表示感谢。
其次向你道歉。
在此。。。。。。。。。。。。
我会再开贴为你加分的。
 
没事,分不重要,开开玩笑。
能解决问题就行了。。。。。对我也有好处。
 
To:yeath,
拦截消息后想弹出自己的菜单,用自定义消息吗?怎样用?
var
。。。
wnd:hwnd;
MyMsg:Cardinal;
const
。。。
My_POPMENUMESSAGE='PopUserMenu'

begin
MyMsg:=RegisterWindowMessage(My_POPMENUMESSAGE);
。。。
if fFlag = true then
begin
wnd:= FINDWINDOW(NIL,'form1');
if wnd>0 then
begin
sendMESSAGE(WND,MyMsg,1,1);
Result:=1;
end
else
begin
Result:=1;
end;
。。。

这样可以吗?
 
注册消息后,通过PostMessage发送消息到你的程序,再在你的程序里对消息进行捕获。
再重载你的wndProc过程。
定义如下: procedure WndProc(var Msg:TMessage);override;
过程代码如下:
procedure TForm1.WndProc(var Msg: TMessage);
var
mBuf:TMemoryStream;
begin
if Msg.Msg=msgmsg then //msgmsg是你的自定义消息。
begin
//你的处理代码

end;
inherited;
end;


 
好像不行,我不知道那里错了。
 
1、钩子加载时正常。但无法卸载,关闭程序可卸载。
2、定义的消息不发送。
3、钩子处理(DLL)函数中加
MyMsg:=RegisterWindowMessage(GST_MESSAGE);
if MyMsg<>0 then
showmessage('成功')
else
showmessage('失败');
理应有按键就 showmessage('成功') 或 showmessage('失败'); 可是无反应。

 
还没有搞明白?这儿有测试程序,源代码。
http://www.iligia.com/chinese/documents/program/dishotkey.htm
除了 Power,Sleep没有办法,其他都能够屏蔽。
 
To: Ligia,
谢谢,我有下载。
 
那还不行吗?
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
procedure WndProc(var Message: TMessage); override;
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
var
wm_sock:integer;
hHandle:HWND;

function LowLevelKeyboardProc(nCode:integer;WParam:WPARAM;LParam:LPARAM):LRESULT;stdcall;
type
KBDLLHOOKSTRUCT=record
vkCode:DWORD;
scanCode:DWORD;
flags:DWORD;
time:DWord;
dwExtraInfo:dword;
end;
var
fFlag:BOOL;
p:^KBDLLHOOKSTRUCT;
begin
result:=0;
fFlag := false;
p:=Pointer(LPARAM);
if (ncode=HC_ACTION) then
begin
case wparam of
WM_KEYDOWN,
WM_SYSKEYDOWN,
WM_KEYUP,
WM_SYSKEYUP:
fFlag :=(p.vkCode = VK_Lwin) or (p.vkCode = VK_Rwin)or (p.vkCode = VK_apps);
end;
end;
if fFlag = true then
begin
PostMessage(hHandle,WM_SOCK,0,0);
Result:=1;
end;
if ncode <> 0 then
Result := CallNextHookEX(0,ncode,wparam,lparam);
end;

procedure TForm1.Button1Click(Sender: TObject);
const
WH_KEYBOARD_LL=13;
begin
wm_sock := 0;
wm_sock := RegisterWindowMessage('wm_sock');
// showmessage(inttostr(wm_sock));
hHandle := Self.Handle;

setwindowshookexw(WH_KEYBOARD_LL,LowLevelKeyboardProc,hinstance,0);
end;

procedure TForm1.WndProc(var Message: TMessage);
begin
if Message.Msg=WM_SOCK then
begin
showmessage('用户按下win键');
end;
inherited;
end;

end.


这是程序,自己看看吧,我是做成EXE的,成功运行.
 
这个贴子收掉吧,老在我参与的问题里,看着不舒服。
 
顶部