先付上我的程式元碼
Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Timer1: TTimer;
Button2: TButton;
ComboBox1: TComboBox;
CheckBox1: TCheckBox;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
ComboBox4: TComboBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
ComboBox5: TComboBox;
CheckBox4: TCheckBox;
Edit1: TEdit;
Label10: TLabel;
Timer2: TTimer;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure CheckBox4Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
視窗程序 : Hwnd;
程序ID : Dword;
遊戲 : Dword;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
視窗程序 :=FindWindow(nil,PChar(ComboBox1.Text)) ;
if 視窗程序 = 0 then
begin
ShowMessage('無此視窗名稱');
end;
遊戲:=OpenProcess(PROCESS_ALL_ACCESS, False, 程序ID);
GetWindowThreadProcessId(視窗程序, 程序ID);
if 遊戲 = 0 then //程序讀取失敗時
begin
showMessage('請先登入人物或檢查是否輸入名稱錯誤'); //跳出錯誤視窗
end;
if 遊戲>0 then
begin
ComboBox1.Enabled := False ; //讓填寫外掛名稱的欄位變灰
TIMER1.ENABLED:= TRUE;
end;
end;
function EnumWndProc(AWnd: HWND; AlParam: LPARAM):Boolean;stdcall;
var
WndCaption: array [0..254] of WideChar;
begin
GetWindowText(AWnd, @WndCaption, 254);
if IsWindowVisible(awnd) then
begin
if (WndCaption[0]<>chr(0)) and (Pos('別墅',WndCaption)=0) then
Form1.ComboBox1.Items.Add(Strpas(WndCaption));
end;
Result := True;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ComboBox1.Items.Clear;
EnumWindows(@EnumWndProc,0);
end;
procedure TForm1.CheckBox4Click(Sender: TObject);
begin
if checkbox4.Checked then //當卡鍵功能勾選時
Begin
label10.Caption:=edit1.Text ; //標籤值(剩餘秒數)讀取為設定值
combobox5.Enabled:=false; //讓按鈕選項無法使用
edit1.Enabled:=false; //讓秒數設定欄無法使用
End
Else //當卡鍵功能取消勾選時
Begin
label10.Caption:='0'; //標籤值(剩餘秒數)恢復為0
combobox5.Enabled:=true; //讓按鈕選項可以再使用
edit1.Enabled:=true; //讓秒數設定欄可以再使用
End;
timer2.Enabled:=checkbox4.Checked ; //在勾選卡鍵功能時才開啟timer
end;
procedure TForm1.edit1Change(Sender: TObject);
begin
try
strtofloat(edit1.Text);
checkbox4.Enabled:=true;
except
checkbox4.Enabled:=false;
End;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
動態基址,人物基址,血量,最大血量,真氣,最大真氣,真元,最大真元,等級,經驗,最大經驗
: dword;
TT:DWORD;
nkey1 : integer;
begin
if combobox5.ItemIndex<9 then //第五組按鈕
Nkey1:=$31+combobox5.ItemIndex
Else
Nkey1:=112+combobox5.ItemIndex -9;
ReadProcessMemory( 遊戲, pointer($A5BFB0+$1C),@動態基址,4,TT );
ReadProcessMemory( 遊戲, pointer(動態基址+$20),@人物基址,4,TT );
ReadProcessMemory( 遊戲, pointer(人物基址+$474),@血量,4,TT );
ReadProcessMemory( 遊戲, pointer(人物基址+$4b4),@最大血量,4,TT );
ReadProcessMemory( 遊戲, pointer(人物基址+$478),@真氣,4,TT );
ReadProcessMemory( 遊戲, pointer(人物基址+$4b8),@最大真氣,4,TT );
ReadProcessMemory( 遊戲, pointer(人物基址+$488),@真元,4,TT );
ReadProcessMemory( 遊戲, pointer(人物基址+$534),@最大真元,4,TT );
ReadProcessMemory( 遊戲, pointer(人物基址+$46C),@等級,4,TT );
ReadProcessMemory( 遊戲, pointer(人物基址+$47C),@經驗,4,TT );
Label1.caption:='人物血量:'+IntToStr(血量)+'/'+IntToStr(最大血量);
Label2.Caption:='人物真氣:'+IntToStr(真氣)+'/'+IntToStr(最大真氣);
Label3.Caption:='人物真元:'+IntToStr(真元)+'/'+IntToStr(最大真元);
Label4.Caption:='人物等級:'+IntToStr(等級);
Label5.Caption:='人物經驗:'+IntToStr(經驗)+'/'+IntToStr(最大經驗);
if checkbox1.Checked and (血量*100/最大血量 < strtoint(ComboBox2.Text)) then //假如勾選血魔保護,而且血魔%低於設定值時
SendMessageW (視窗程序,WM_KEYDOWN ,55,0); //發送鍵盤訊息
if checkbox1.Checked and (真氣*100/最大真氣 < strtoint(ComboBox3.Text)) then //假如勾選血魔保護,而且血魔%低於設定值時
SendMessageW (視窗程序,WM_KEYDOWN ,56,0); //發送鍵盤訊息
if checkbox1.Checked and (真元 > strtoint(ComboBox4.Text)) then //假如勾選血魔保護,而且血魔%低於設定值時
SendMessageW (視窗程序,WM_KEYDOWN ,57,0); //發送鍵盤訊息
end;
procedure TForm1.Timer2Timer(Sender: TObject);
begin
label10.Caption :=floattostr((strtofloat(label10.Caption)*10-1)/10); //剩餘秒數,每次減少0.1
if strtofloat(label10.Caption)<=0 then //當標籤內數值(讀秒)減少到0時
SendMessageW (視窗程序,WM_KEYDOWN ,nkey1,0); //發送卡鍵訊息
if strtofloat(label10.Caption)<=0 then //當標籤內數值(讀秒)減少到0時
label10.Caption:=edit1.Text ; //將標籤值再回覆到設定秒數
end;
end.
請問各位大大為何我執行程式但一值顯示錯誤
請問這一行的錯是錯在哪裡ㄋ
請會ㄉ大大幫幫忙一下...謝謝 |