如题,谢谢
解决方案 »
- 小弟初学,哪位能详细说明下,高分相送,感激不尽.
- 调用dll中函数出现访问0地址错误
- 如何用delphi语言给dll文建会加密
- 多线程问题,请高手进来指点一下。
- pb,vb,delphi的详解
- 小弟想在MU这样的OPEN GL游戏中做个窗口以方便地图查询不知怎样实现请赐教
- 言者有分
- 请教一个DLL兼容性的问题??? 100分
- 在线求教:我做一个串口软件,运行时出现一个“Range Check Error"的提示,请问是什么意思?该如何解决。高分求教!!!!
- 有那位大虾知道ReportBuild5.5 那里下载?
- mismatch in datapacket!!各位大虾请留步!
- 请问大家是如何避免用户在修改或者追加后没有保存,乱点list数据的?
相信对你有用
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Function KbHook( code: Integer; wparam: Word; lparam: LongInt ): LRESULT;stdcall;
var
Form1: TForm1;
oldHook:Hhook;
implementation{$R *.dfm}
Function KbHook( code: Integer; wparam: Word; lparam: LongInt ): LRESULT;stdcall;
var temp,KeyValue:UINT;
ks: TkeyBoardState;
Begin
result:=0;
If code < 0 Then
begin
result:= CallNextHookEx( oldHook, code, wparam, lparam );
end
Else begin
if pEventMSG(lParam)^.message=WM_KEYDOWN then
begin
KeyValue:=pEventMSG(lParam)^.paramL mod 256;
GetKeyboardState(ks);
if (KeyValue>=65) and (KeyValue<92)then
begin
if (ks[VK_CAPITAL]<>1) then
if ks[VK_SHIFT]and $80<>0 then
temp:=KeyValue
else
temp:=KeyValue+32
else
if ks[VK_SHIFT]and $80<>0 then
temp:=KeyValue+32
else
temp:=KeyValue;
end
else if(KeyValue>=96)and(KeyValue<106) then
temp:=KeyValue-48
else if(KeyValue>=112)and(KeyValue<124) then
begin
Form1.Label1.Caption:='F'+IntTostr(KeyValue-111)+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=13 then
begin
Form1.Label1.Caption:='Enter'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=32 then
begin
Form1.Label1.Caption:='Space'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=16 then
begin
Form1.Label1.Caption:='Shift'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=17 then
begin
Form1.Label1.Caption:='Ctrl or Alt'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=20 then
begin
Form1.Label1.Caption:='Caps Lock'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=9 then
begin
Form1.Label1.Caption:='Tab'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=188 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='<'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:=','+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=190 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='>'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='.'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=191 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='?'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='/'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=192 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='~'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='`'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=189 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='_'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='-'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=187 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='+'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='='+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=220 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='|'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='\'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=46 then
begin
Form1.Label1.Caption:='Delete'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=35 then
begin
Form1.Label1.Caption:='End'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=27 then
begin
Form1.Label1.Caption:='ESC'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=8 then
begin
Form1.Label1.Caption:='Back Sapce'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=45 then
begin
Form1.Label1.Caption:='Insert'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=33 then
begin
Form1.Label1.Caption:='Page Up'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=34 then
begin
Form1.Label1.Caption:='Page Down'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=36 then
begin
Form1.Label1.Caption:='Hone'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=38 then
begin
Form1.Label1.Caption:='Up'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=37 then
begin
Form1.Label1.Caption:='Left'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=40 then
begin
Form1.Label1.Caption:='Down'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=39 then
begin
Form1.Label1.Caption:='Right'+': '+INTtoStr(KeyValue);
exit;
end
begin
Form1.Label1.Caption:='+'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=109 then
begin
Form1.Label1.Caption:='-'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=111 then
begin
Form1.Label1.Caption:='/'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=106 then
begin
Form1.Label1.Caption:='*'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=219 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='{'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='['+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=221 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='}'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:=']'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=110 then
begin
Form1.Label1.Caption:='.'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=186 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:=':'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:=';'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=222 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='”'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='’'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=49 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='!'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='1'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=50 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='@'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='2'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=51 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='#'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='3'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=52 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='$'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='4'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=53 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='%'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='5'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=54 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='^'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='6'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=55 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='&'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='7'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=56 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='*'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='8'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=57 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:='('+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='9'+': '+INTtoStr(KeyValue);
exit;
end
else if Keyvalue=48 then
begin
if ks[VK_SHIFT]and $80<>0 then
Form1.Label1.Caption:=')'+': '+INTtoStr(KeyValue)
else
Form1.Label1.Caption:='0'+': '+INTtoStr(KeyValue);
exit;
end
else
temp:=KeyValue; Form1.Label1.Caption:=char(temp)+': '+INTtoStr(temp); end;
end;
End; // KbHookprocedure TForm1.Button1Click(Sender: TObject);
begin
if oldHook=0 then
oldHook := SetWindowsHookEx( WH_JOURNALRECORD, @KbHook, HInstance, 0);end;
procedure TForm1.Button2Click(Sender: TObject);
begin
If oldHook <> 0 Then
Begin
UnhookWindowshookEx( oldHook );
oldHook := 0;
End; // Ifend;end.
这句有用
我找到了,谢谢!