†PreDatoR†
04.04.2011, 20:16
В принцепе проблему решил
unit Unit1;
interface
uses
Windows, Messages, ShellApi,SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
HookHandle: hHook;
implementation
{$R *.dfm}
function HookProc(Code: integer; WParam: word; LParam: Longint): Longint; stdcall;
var
msg: PEVENTMSG;
begin
if Code >= 0 then begin
result := 0;
msg := Pointer(LParam);
with Form1 do
if msg.message = WM_LBUTTONDOWN then
keybd_event(Ord('L'), 0,0, 0);
end
else
result := CallNextHookEx(HookHandle, code, WParam, LParam);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
HookHandle := SetWindowsHookEx(0,
@HookProc, HInstance, 0);
end;
end.
unit Unit1;
interface
uses
Windows, Messages, ShellApi,SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
HookHandle: hHook;
implementation
{$R *.dfm}
function HookProc(Code: integer; WParam: word; LParam: Longint): Longint; stdcall;
var
msg: PEVENTMSG;
begin
if Code >= 0 then begin
result := 0;
msg := Pointer(LParam);
with Form1 do
if msg.message = WM_LBUTTONDOWN then
keybd_event(Ord('L'), 0, 0, 0);
end
else
result := CallNextHookEx(HookHandle, code, WParam, LParam);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
HookHandle := SetWindowsHookEx(0,
@HookProc, HInstance, 0);
end;
end.
Эти циклы повторяющиеся.
По первому коду: симуляция должна идти по нажатию мыши, но она продолжается ждаже после закрытия программы.
Как можно жто всё усовершенствовать.
Симуляция клавиши - это хоткей в СЕ.
unit Unit1;
interface
uses
Windows, Messages, ShellApi,SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
HookHandle: hHook;
implementation
{$R *.dfm}
function HookProc(Code: integer; WParam: word; LParam: Longint): Longint; stdcall;
var
msg: PEVENTMSG;
begin
if Code >= 0 then begin
result := 0;
msg := Pointer(LParam);
with Form1 do
if msg.message = WM_LBUTTONDOWN then
keybd_event(Ord('L'), 0,0, 0);
end
else
result := CallNextHookEx(HookHandle, code, WParam, LParam);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
HookHandle := SetWindowsHookEx(0,
@HookProc, HInstance, 0);
end;
end.
unit Unit1;
interface
uses
Windows, Messages, ShellApi,SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
HookHandle: hHook;
implementation
{$R *.dfm}
function HookProc(Code: integer; WParam: word; LParam: Longint): Longint; stdcall;
var
msg: PEVENTMSG;
begin
if Code >= 0 then begin
result := 0;
msg := Pointer(LParam);
with Form1 do
if msg.message = WM_LBUTTONDOWN then
keybd_event(Ord('L'), 0, 0, 0);
end
else
result := CallNextHookEx(HookHandle, code, WParam, LParam);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
HookHandle := SetWindowsHookEx(0,
@HookProc, HInstance, 0);
end;
end.
Эти циклы повторяющиеся.
По первому коду: симуляция должна идти по нажатию мыши, но она продолжается ждаже после закрытия программы.
Как можно жто всё усовершенствовать.
Симуляция клавиши - это хоткей в СЕ.