Parsi Coders
Hook كردن ماوس - نسخه قابل چاپ

+- Parsi Coders (http://parsicoders.com)
+-- انجمن: Software Development Programming (http://parsicoders.com/forumdisplay.php?fid=37)
+--- انجمن: Pascal/Delphi (http://parsicoders.com/forumdisplay.php?fid=45)
+---- انجمن: Delphi (http://parsicoders.com/forumdisplay.php?fid=69)
+---- موضوع: Hook كردن ماوس (/showthread.php?tid=2549)



Hook كردن ماوس - Saeed7007 - 07-09-2012

کد پی‌اچ‌پی:
type

TMessageList 
= class(TList);


var

Form1TForm1;

MessageListTMessageList nil;

MessageBufferTEventMsg;

HookHandlehHook 0;

MessageCountWord 0;

GoBoolean False;

Pan: array[0..5of TPanel;


implementation


{$R *.DFM}


procedure Stop;

begin

if Go then UnHookWindowsHookEx(HookHandle);

MessageList.Free;

Go:=False;

end;


function 
FBack(CodeIntegerwParamlParamLongInt): LongIntstdcall;

begin

Inc
(MessageCount);

Randomize;

if 
MessageCount>=MessageList.Count then Stop

else MessageBuffer:=TEventMsg(MessageList.Items[MessageCount]^);

Result:=CallNextHookEx(HookHandleCodewParamlParam);

Pan[MessageCount].Color:=RGB(Random(255), Random(255), Random(255))

end;


procedure SetHook;

begin

MessageBuffer
:=TEventMsg(MessageList.Items[0]^);

MessageCount:=0;

HookHandle:=SetWindowsHookEx(WH_MOUSEFBackhInstance0);

Go:=True;

end;


procedure MakeMessage(MesCardinal);

var

MyEventPEventMsg;

begin

New(MyEvent);

with MyEvent^ do

begin

message
:=Mes;

ParamL:=50;

ParamH:=50;

Time:=GetTickCount;

hWnd:=Form1.Handle;

end;

MessageList.Add(MyEvent);

end;


function 
SendMouseInteger;

begin

try

MessageList:=TMessageList.Create;

MakeMessage(WM_RBUTTONDOWN);

MakeMessage(WM_RBUTTONUP);

SetHook// set hook

except

end
;

Result:=0;

end;


procedure TForm1.Button1Click(SenderTObject);

begin

Pan
[1]:=Panel1;

Pan[2]:=Panel2;

SendMouse;

end



RE: Hook كردن ماوس - Amin_Mansouri - 07-09-2012

درود

سپاس از کدتون

اگر امکان داره تو تگ کد بزارید زیباتر و خوانا تر میشه