红蓝保护(按键模拟)

//使用物品方式
 
 
//内存模拟快捷栏方式
红蓝保护(按键模拟)
 
 
//SendMessage按键模拟
红蓝保护(按键模拟)
var
   Form1 :  TForm1 ;
/////////////////////////////////////////////////////////////
   MyHwnd : HWND ;
   MyPid : Dword ;
   MyProcess : Thandle ;
   MyPointer : Integer ;
   Readbyte : DWORD ; //Size_T
   HpMin , HpMax : Integer ;
   MpMin , MpMax : Integer ;
   hp_half , mp_half : Integer ;
   RoleName : array  [ 0..16 ]  of  WideChar ; // UniCode 0..17个字符加起来共18个字符
/////////////////////////////////////////////////////////////
Const
     BaseAddress = $924E0C ;
         Offset1 = $1C ;
         Offset2 = $20 ;
       RNOffset1 = $5CC ;
       RNOffset2 = $0 ;
       HpMinOffset = $450 ;
       HpMaxOffset = $478 ;
       MpMinOffset = $454 ;
       MpMaxOffset = $47C ;
implementation

{$R *.dfm}

function  SendKey ( Str : string ): Integer ;
var
   MyHwnd : HWND ;
   KeyValue : integer ;
begin
   {功能模拟发送按键:1~9,F1~F8}
     MyHwnd := FindWindow ( nil , 'Element Client' );
    if  Str = '1'   then  KeyValue := 49 ;
    if  Str = '2'   then  KeyValue := 50 ;
    if  Str = '3'   then  KeyValue := 51 ;
    if  Str = '4'   then  KeyValue := 52 ;
    if  Str = '5'   then  KeyValue := 53 ;
    if  Str = '6'   then  KeyValue := 54 ;
    if  Str = '7'   then  KeyValue := 55 ;
    if  Str = '8'   then  KeyValue := 56 ;
    if  Str = '9'   then  KeyValue := 57 ;
    if  Str = 'F1'  then  KeyValue := VK_F1 ;
    if  Str = 'F2'  then  KeyValue := VK_F2 ;
    if  Str = 'F3'  then  KeyValue := VK_F3 ;
    if  Str = 'F4'  then  KeyValue := VK_F4 ;
    if  Str = 'F5'  then  KeyValue := VK_F5 ;
    if  Str = 'F6'  then  KeyValue := VK_F6 ;
    if  Str = 'F7'  then  KeyValue := VK_F7 ;
    if  Str = 'F8'  then  KeyValue := VK_F8 ;
   sendmessage ( MyHwnd , wm_keydown , KeyValue , 0 );
   sendmessage ( MyHwnd , wm_keyup , KeyValue , 0 );
end ;

procedure  TForm1 . Timer1Timer ( Sender :  TObject );
begin
   MyHwnd := FindWindow ( NIL , 'Element Client' );
   GetWindowThreadProcessId ( MyHwnd ,@ myPid );
   MyProcess := OpenProcess ( PROCESS_ALL_ACCESS , false , myPid );
   ReadProcessMemory ( MyProcess , Pointer ( BaseAddress ),@ MyPointer , 4 , Readbyte );
   ReadProcessMemory ( MyProcess , Pointer ( MyPointer + Offset1 ),@ MyPointer , 4 , Readbyte );
   ReadProcessMemory ( MyProcess , Pointer ( MyPointer + Offset2 ),@ MyPointer , 4 , Readbyte );
   ReadProcessMemory ( MyProcess , Pointer ( MyPointer + HpMinOffset ),@ HpMin , 4 , Readbyte );
   ReadProcessMemory ( MyProcess , Pointer ( MyPointer + HpMaxOffset ),@ HpMax , 4 , Readbyte );
   ReadProcessMemory ( MyProcess , Pointer ( MyPointer + MPMinOffset ),@ MPMin , 4 , Readbyte );
   ReadProcessMemory ( MyProcess , Pointer ( MyPointer + MPMaxOffset ),@ MPMax , 4 , Readbyte );
   ReadProcessMemory ( MyProcess , Pointer ( MyPointer + RNOffset1 ),@ MyPointer , 4 , Readbyte );
   ReadProcessMemory ( MyProcess , Pointer ( MyPointer + RNOffset2 ),@ RoleName , 32 , Readbyte );
   CloseHandle ( MyProcess );
   //显示信息
   Form1 . Label1 . Caption := '【' + RoleName + '】  HP:' + intTostr ( HpMin )+ '/' + intTostr ( HpMax )+
                          '  MP:' + intTostr ( MPMin )+ '/' + intTostr ( MPMax );

   hp_half :=( HpMax  div  2 );
   mp_half :=( Mpmax  div  2 );
end ;

procedure  TForm1 . Timer2Timer ( Sender :  TObject );
begin
  if  CheckBox1 . Checked  then
  if  ( HpMin <= StrToInt ( Edit1 . Text ))  then
  begin
    //使用红
     SendKey ( ComboBox1 . Text );
  end ;

  if  CheckBox2 . Checked  then
  if  MpMin <= StrToInt ( Edit2 . Text )  then
  begin
    //使用蓝
    SendKey ( ComboBox2 . Text );
  end ;
end ;

procedure  TForm1 . Edit1DblClick ( Sender :  TObject );
begin
   Edit1 . Text := IntToStr ( hp_half );
   Edit2 . Text := IntToStr ( mp_half );
end ;
procedure  TForm1 . CheckBox1Click ( Sender :  TObject );
begin
     if  CheckBox1 . Checked  then
       Edit1 . Enabled := False
     else
       Edit1 . Enabled := True ;
end ;

procedure  TForm1 . CheckBox2Click ( Sender :  TObject );
begin
     if  CheckBox2 . Checked  then
       Edit2 . Enabled := False
     else
       Edit2 . Enabled := True ;
end ;




附件列表

     

    你可能感兴趣的:(模拟)