M
myqq
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;<br><br>interface<br><br>uses<br>Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>StdCtrls;<br><br>type<br>TForm1 = class(TForm)<br>Button1: TButton;<br>Button2: TButton;<br>Button3: TButton;<br>Edit1: TEdit;<br>Button4: TButton;<br> ListBox1: TListBox;<br>procedure FormCreate(Sender: TObject);<br>procedure Button1Click(Sender: TObject);<br>procedure Button2Click(Sender: TObject);<br>procedure Button3Click(Sender: TObject);<br> procedure Button4Click(Sender: TObject);<br>private<br>{ Private declarations }<br>public<br>{ Public declarations }<br>end;<br><br>var<br>Form1: TForm1;<br><br>eventdata:Tmemorystream;<br>EventArr:array[0..1000]of EVENTMSG;<br>Event:EVENTMSG;<br>EventLog:Integer;<br>PlayLog:Integer;<br>hHook,hPlay:Integer;<br>recOK:Integer;<br>canPlay:Integer;<br>bDelay:Bool;<br>implementation<br><br>{$R *.DFM}<br>Function PlayProc(iCode:Integer;wParam:wParam;lParam:lParam):LRESULT;stdcall;<br>begin<br>canPlay:=1;<br>Result:=0;<br><br>if iCode < 0 then //±&Oslash;&ETH;&euml;&frac12;&laquo;&Iuml;&ucirc;&Iuml;&cent;&acute;&laquo;&micro;&Yacute;&micro;&frac12;&Iuml;&ucirc;&Iuml;&cent;&Aacute;&acute;&micro;&Auml;&Iuml;&Acirc;&Ograve;&raquo;&cedil;&ouml;&frac12;&Oacute;&Ecirc;&Uuml;&micro;&yen;&Ocirc;&ordf;<br>Result := CallNextHookEx(hPlay,iCode,wParam,lParam)<br>else if iCode = HC_SYSMODALON then<br>canPlay:=0<br>else if iCode = HC_SYSMODALOFF then<br>canPlay:=1<br>else if ((canPlay =1 )and(iCode=HC_GETNEXT)) then begin<br>if bDelay then begin<br>bDelay:=False;<br>Result:=50;<br>end;<br>Eventdata.read(Event,sizeof(Event));<br><br>pEventMSG(lParam)^:=Event;<br>//pEventMSG(lParam)^:=EventArr[PlayLog];<br>end<br>else if ((canPlay = 1)and(iCode = HC_SKIP))then begin<br>bDelay := True;<br>PlayLog:=PlayLog+1;<br>end;<br>//if PlayLog>=EventLog then begin<br>if eventdata.Position>eventdata.size-1 then begin<br>UNHookWindowsHookEx(hPlay);<br>end;<br>end;<br><br>function HookProc(iCode:Integer;wParam:wParam;lParam:lParam):LRESULT;stdcall;<br>begin<br>recOK:=1;<br>Result:=0;<br><br>if iCode < 0 then<br>Result := CallNextHookEx(hHook,iCode,wParam,lParam)<br>else if iCode = HC_SYSMODALON then<br>recOK:=0<br>else if iCode = HC_SYSMODALOFF then<br>recOK:=1<br>else if ((recOK>0) and (iCode = HC_ACTION)) then begin<br>EventArr[EventLog]:=pEventMSG(lParam)^;<br>Event:=EventArr[EventLog];<br>form1.caption:=inttostr(sizeof(Event));<br>Eventdata.write(Event,sizeof(Event));<br>EventLog:=EventLog+1;<br><br>if EventLog>=1000 then begin<br>UnHookWindowsHookEx(hHook);<br>end;<br>end;<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>eventdata:=Tmemorystream.create;<br>Button1.Caption:='&frac14;&Iacute;&Acirc;&frac14;';<br>Button2.Caption:='&Iacute;&pound;&Ouml;&sup1;';<br>Button3.Caption:='&raquo;&Oslash;·&Aring;';<br>Button4.Caption:='±&pound;&acute;&aelig;';<br>Button2.Enabled:=False;<br>Button3.Enabled:=False;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>EventLog:=0;<br>eventdata.Clear;<br>eventdata.Seek(0,soFromBeginning);<br>//&frac12;¨&Aacute;&cent;&frac14;ü&Aring;&Igrave;&Ecirc;ó±ê&sup2;&Ugrave;×÷&Iuml;&ucirc;&Iuml;&cent;&frac14;&Iacute;&Acirc;&frac14;&Aacute;&acute;<br>hHook:=SetwindowsHookEx(WH_JOURNALRECORD,HookProc,HInstance,0);<br>//eventdata.write('End',20);<br>Button2.Enabled:=True;<br>Button1.Enabled:=False;<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>UnHookWindowsHookEx(hHook);<br>hHook:=0;<br><br>Button1.Enabled:=True;<br>Button2.Enabled:=False;<br>Button3.Enabled:=True;<br>end;<br><br>procedure TForm1.Button3Click(Sender: TObject);<br>begin<br>PlayLog:=0;<br>eventdata.Seek(0,soFromBeginning);<br>//&frac12;¨&Aacute;&cent;&frac14;ü&Aring;&Igrave;&Ecirc;ó±ê&sup2;&Ugrave;×÷&Iuml;&ucirc;&Iuml;&cent;&frac14;&Iacute;&Acirc;&frac14;&raquo;&Oslash;·&Aring;&Aacute;&acute;<br>hPlay:=SetwindowsHookEx(WH_JOURNALPLAYBACK,PlayProc,<br>HInstance,0);<br><br>//Button3.Enabled:=False;<br>end;<br><br>procedure TForm1.Button4Click(Sender: TObject);<br>begin<br>eventdata.SaveToFile('c:/data.1');<br>//EventArr[PlayLog];<br>end;<br><br>end.<br>