unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ShellAPI, Menus, ExtCtrls;
type
TForm1 =
class(TForm)
Edit1: TEdit;
Timer1: TTimer;
Label1: TLabel;
procedure FormHide(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Edit1KeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
key1:
String;
implementation
const
WH_KEYBOARD_LL = 13;
type
PKbDllHookStruct = ^TKbDllHookStruct;
TKbDllHookStruct =
packed record
vkCode: Cardinal;
scanCode: Cardinal;
flags: Cardinal;
time: Cardinal;
end;
var
HookHandle: Cardinal;
{$R *.dfm}
// Tastatur HOOK
function LLKeyboardHookProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT;
stdcall;
begin
key1:='
';
if nCode = HC_ACTION
then
with PKbDllHookStruct(lParam)^
do
key1:=(Format('
%4.4x %2.2x %2.2x %2.2x ', [wParam, vkCode, scanCode, flags]));
Result := CallNextHookEx(HookHandle, nCode, wParam, lParam);
end;
// Abfrage
procedure TForm1.Edit1KeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
if (Key=VK_RETURN)
then
begin
if edit1.Text='
tttt'
then WinExec('
C:\Programme\ttt.exe',1);
if edit1.Text='
quit'
then close();
edit1.Text:='
';
Form1.Left:=-150;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
// Lässt das Fenster aus der unteren Programmleiste verschwinden
ShowWindow( Application.Handle, SW_HIDE );
SetWindowLong( Application.Handle, GWL_EXSTYLE,
GetWindowLong(Application.Handle, GWL_EXSTYLE)
or
WS_EX_TOOLWINDOW
and not WS_EX_APPWINDOW);
ShowWindow( Application.Handle, SW_SHOW );
//-------------------//
Form1.Left:=-150
end;
procedure TForm1.FormHide(Sender: TObject);
begin
if HookHandle <> 0
then begin
UnhookWindowsHookEx(HookHandle);
HookHandle := 0;
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Form1.SetFocus;
Edit1.Focused;
key1:='
';
HookHandle := SetWindowsHookEx(WH_KEYBOARD_LL, LLKeyboardHookProc, hInstance, 0);
if HookHandle = 0
then RaiseLastOSError;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if key1='
0100 73 3E 00 '
then
begin
Form1.Left:=+600;
Form1.SetFocus;
label1.caption:=key1;
end;
end;
end.