📄 fmmain.pas
字号:
unit fmMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ComCtrls, StdCtrls, Gauges, IniFiles, XPMan, Grids,
ValEdit, Buttons, CoolTrayIcon;
type
TPropType = record
Checked: Boolean;
Value: Integer;
Key: string;
end;
TSkillType = record
Checked: Boolean;
Text: string;
Value: Integer;
Key: string;
end;
TfrmMain = class(TForm)
gMp: TGauge;
Label2: TLabel;
lblMp: TLabel;
ScrollBox1: TScrollBox;
lblAuto1: TLabel;
lblAuto2: TLabel;
lblAuto3: TLabel;
lblAuto4: TLabel;
lblAuto5: TLabel;
lblAuto6: TLabel;
chkAuto1: TCheckBox;
edtAuto1: TEdit;
cbbAuto1: TComboBox;
chkAuto2: TCheckBox;
edtAuto2: TEdit;
cbbAuto2: TComboBox;
chkAuto3: TCheckBox;
edtAuto3: TEdit;
cbbAuto3: TComboBox;
chkAuto4: TCheckBox;
edtAuto4: TEdit;
cbbAuto4: TComboBox;
chkAuto5: TCheckBox;
edtAuto5: TEdit;
cbbAuto5: TComboBox;
chkAuto6: TCheckBox;
edtAuto6: TEdit;
cbbAuto6: TComboBox;
chkHp1: TCheckBox;
edtHp1: TEdit;
cbbHp1: TComboBox;
chkHp2: TCheckBox;
edtHp2: TEdit;
cbbHp2: TComboBox;
chkHp3: TCheckBox;
edtHp3: TEdit;
cbbHp3: TComboBox;
chkMp1: TCheckBox;
edtMp1: TEdit;
cbbMp1: TComboBox;
chkMp2: TCheckBox;
edtMp2: TEdit;
cbbMp2: TComboBox;
btnSave: TButton;
btnClose: TButton;
chkAutoGet: TCheckBox;
Label1: TLabel;
lblHp: TLabel;
gHp: TGauge;
btnShow: TBitBtn;
pnl1: TPanel;
ImgSelCls: TImage;
edtBaseAddr: TEdit;
lbl1: TLabel;
chkStart: TCheckBox;
edtChrName: TEdit;
Label3: TLabel;
tryIco: TCoolTrayIcon;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure btnSaveClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
procedure btnShowClick(Sender: TObject);
procedure chkAuto1Click(Sender: TObject);
procedure ImgSelClsMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure ImgSelClsMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
private
FHotKey:Boolean;
FProp: array[1..5] of TPropType;
FSkill: array[1..6] of TSkillType;
procedure ReAlign;
{ Private declarations }
procedure wmnchittest(var msg: twmnchittest); message wm_nchittest;
function GetProp(Idx: Integer): TPropType;
procedure SetProp(Idx: Integer; const Value: TPropType);
function GetSkill(Idx: Integer): TSkillType;
procedure SetSkill(Idx: Integer; const Value: TSkillType);
function GetSkillValue(Idx: Integer): Integer;
procedure SetSkillValue(Idx: Integer; const Value: Integer);
procedure SetProgress(Idx: Integer; const Value: string);
protected
procedure WMHotKey(var msg: TMessage); message WM_HOTKEY;
public
ProgPath: string;
procedure GetChrSetting;
procedure SetTitle(str: string);
{ Public declarations }
property Prop[Idx: Integer]: TPropType read GetProp write SetProp;
property Skill[Idx: Integer]: TSkillType read GetSkill write SetSkill;
property SkillValue[Idx: Integer]: Integer read GetSkillValue write SetSkillValue;
property SkillProgress[Idx: Integer]: string write SetProgress;
end;
var
frmMain: TfrmMain;
implementation
uses uIniOption, uDefine, uSearch, uDeal;
{$R *.dfm}
procedure TfrmMain.ReAlign;
begin
Left := 0; //Screen.Width - Width;
Top := 0;
end;
procedure TfrmMain.FormCreate(Sender: TObject);
begin
ProgPath := ExtractFilePath(Application.ExeName);
Screen.Cursors[10] := LoadCursor(HInstance, 'SelCur');
Application.Title := Caption;
edtChrName.Text := '暂无角色';
BorderStyle := bsNone;
Self.Height := 178+(176-145);
Self.Width := 373;
ReAlign;
chkStart.Enabled := False;
tryIco.Icon := Application.Icon;
tryIco.Hint := edtChrName.Text;
tryIco.IconVisible := True;
FHotKey:=RegisterHotKey(Handle, 123, MOD_CONTROL, VK_END);
end;
procedure TfrmMain.GetChrSetting;
var
Ini: TIniFile;
i: Integer;
begin
Ini := TIniFile.Create(ProgPath + GameChr.ChrName + '.ini');
try
IniOptions.LoadSettings(Ini);
finally
Ini.Free;
end;
chkHp1.Checked:=True;//生命
chkMp1.Checked:=True;//法术
end;
procedure TfrmMain.FormDestroy(Sender: TObject);
begin
frmMain := nil;
end;
procedure TfrmMain.btnSaveClick(Sender: TObject);
begin
IniOptions.SaveToFile(ProgPath + GameChr.ChrName + '.ini');
end;
procedure TfrmMain.btnCloseClick(Sender: TObject);
begin
Self.Close;
end;
procedure TfrmMain.wmnchittest(var msg: twmnchittest);
begin
inherited;
if (htclient = msg.result) then
msg.result := htcaption;
end;
procedure TfrmMain.btnShowClick(Sender: TObject);
begin
if Self.Height > 30 then
Self.Height := 30
else
begin
if GameChr.ZtHwnd<>0 then
Self.Height := 178
else
Self.Height:=178+(176-145);
end;
end;
procedure TfrmMain.chkAuto1Click(Sender: TObject);
var
s: string;
Idx: Integer;
begin
s := TCheckBox(Sender).Name;
Idx := StrToInt(s[Length(s)]);
SkillValue[Idx] := 0;
end;
procedure TfrmMain.SetTitle(str: string);
begin
Application.Title := str;
end;
procedure TfrmMain.ImgSelClsMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbRight then
Exit;
ReAlign;
ImgSelCls.Visible := False;
Screen.Cursor := 10;
end;
procedure TfrmMain.ImgSelClsMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
aHwnd: hwnd;
aName: array[0..255] of Char;
sClassName, sCaption: string;
begin
Screen.Cursor := crDefault;
ImgSelCls.Visible := True;
aHwnd := WindowFromPoint(Point(Mouse.CursorPos.X, Mouse.CursorPos.Y));
GetClassName(aHwnd, aName, 256);
sClassName := aName;
GetWindowText(aHwnd, aName, 256);
sCaption := aName;
if Pos('征途正式版', sCaption) > 0 then
begin
chkStart.Enabled := True;
GameChr.NeedSearchName := True;
GameChr.ztClassName := sClassName;
chkStart.Enabled := True;//开始挂机
chkStart.Checked := True;
chkAutoGet.Checked := True;
ScrollBox1.Height:=145;
Height:=178;
GameChr.BaseAddr := StrToInt('$' + edtBaseAddr.Text);
ThreadSearch.Resume;
ThreadDeal.Resume;
end;
end;
function TfrmMain.GetProp(Idx: Integer): TPropType;
begin
case Idx of
1:
begin
Result.Checked := chkHp1.Checked;
Result.Value := StrToInt(edtHp1.text);
Result.Key := cbbHp1.Text;
end;
2:
begin
Result.Checked := chkHp2.Checked;
Result.Value := StrToInt(edtHp2.text);
Result.Key := cbbHp2.Text;
end;
3:
begin
Result.Checked := chkHp3.Checked;
Result.Value := StrToInt(edtHp3.text);
Result.Key := cbbHp3.Text;
end;
4:
begin
Result.Checked := chkMp1.Checked;
Result.Value := StrToInt(edtMp1.text);
Result.Key := cbbMp1.Text;
end;
5:
begin
Result.Checked := chkMp2.Checked;
Result.Value := StrToInt(edtMp2.text);
Result.Key := cbbMp2.Text;
end;
end;
end;
procedure TfrmMain.SetProp(Idx: Integer; const Value: TPropType);
begin
FProp[Idx] := Value;
case Idx of
1:
begin
chkHp1.Checked := FProp[Idx].Checked;
edtHp1.Text := IntToStr(Fprop[Idx].Value);
cbbHp1.ItemIndex := cbbHp1.Items.IndexOf(Fprop[Idx].Key);
end;
2:
begin
chkHp2.Checked := FProp[Idx].Checked;
edtHp2.Text := IntToStr(Fprop[Idx].Value);
cbbHp2.ItemIndex := cbbHp1.Items.IndexOf(Fprop[Idx].Key);
end;
3:
begin
chkHp3.Checked := FProp[Idx].Checked;
edtHp3.Text := IntToStr(Fprop[Idx].Value);
cbbHp3.ItemIndex := cbbHp1.Items.IndexOf(Fprop[Idx].Key);
end;
4:
begin
chkMp1.Checked := FProp[Idx].Checked;
edtMp1.Text := IntToStr(Fprop[Idx].Value);
cbbMp1.ItemIndex := cbbHp1.Items.IndexOf(Fprop[Idx].Key);
end;
5:
begin
chkMp2.Checked := FProp[Idx].Checked;
edtMp2.Text := IntToStr(Fprop[Idx].Value);
cbbMp2.ItemIndex := cbbHp1.Items.IndexOf(Fprop[Idx].Key);
end;
end;
end;
function TfrmMain.GetSkill(Idx: Integer): TSkillType;
begin
case Idx of
1:
begin
Result.Checked := chkAuto1.Checked;
Result.Text := edtAuto1.Text;
Result.Value := FSkill[Idx].Value;
Result.Key := cbbAuto1.Text;
end;
2:
begin
Result.Checked := chkAuto2.Checked;
Result.Text := edtAuto2.Text;
Result.Value := FSkill[Idx].Value;
Result.Key := cbbAuto2.Text;
end;
3:
begin
Result.Checked := chkAuto3.Checked;
Result.Text := edtAuto3.Text;
Result.Value := FSkill[Idx].Value;
Result.Key := cbbAuto3.Text;
end;
4:
begin
Result.Checked := chkAuto4.Checked;
Result.Text := edtAuto4.Text;
Result.Value := FSkill[Idx].Value;
Result.Key := cbbAuto4.Text;
end;
5:
begin
Result.Checked := chkAuto5.Checked;
Result.Text := edtAuto5.Text;
Result.Value := FSkill[Idx].Value;
Result.Key := cbbAuto5.Text;
end;
6:
begin
Result.Checked := chkAuto6.Checked;
Result.Text := edtAuto6.Text;
Result.Value := FSkill[Idx].Value;
Result.Key := cbbAuto6.Text;
end;
end;
end;
procedure TfrmMain.SetSkill(Idx: Integer; const Value: TSkillType);
begin
FSkill[Idx] := Value;
case Idx of
1:
begin
chkAuto1.Checked := FProp[Idx].Checked;
edtAuto1.Text := FSkill[Idx].Text;
cbbAuto1.ItemIndex := cbbAuto1.Items.IndexOf(FSkill[Idx].Key);
end;
2:
begin
chkAuto2.Checked := FProp[Idx].Checked;
edtAuto2.Text := FSkill[Idx].Text;
cbbAuto2.ItemIndex := cbbAuto1.Items.IndexOf(FSkill[Idx].Key);
end;
3:
begin
chkAuto3.Checked := FProp[Idx].Checked;
edtAuto3.Text := FSkill[Idx].Text;
cbbAuto3.ItemIndex := cbbAuto1.Items.IndexOf(FSkill[Idx].Key);
end;
4:
begin
chkAuto4.Checked := FProp[Idx].Checked;
edtAuto4.Text := FSkill[Idx].Text;
cbbAuto4.ItemIndex := cbbAuto1.Items.IndexOf(FSkill[Idx].Key);
end;
5:
begin
chkAuto5.Checked := FProp[Idx].Checked;
edtAuto5.Text := FSkill[Idx].Text;
cbbAuto5.ItemIndex := cbbAuto1.Items.IndexOf(FSkill[Idx].Key);
end;
6:
begin
chkAuto6.Checked := FProp[Idx].Checked;
edtAuto6.Text := FSkill[Idx].Text;
cbbAuto6.ItemIndex := cbbAuto1.Items.IndexOf(FSkill[Idx].Key);
end;
end;
end;
function TfrmMain.GetSkillValue(Idx: Integer): Integer;
begin
Result := FSkill[Idx].Value;
end;
procedure TfrmMain.SetSkillValue(Idx: Integer; const Value: Integer);
begin
FSkill[Idx].Value := Value;
case Idx of
1: lblAuto1.Caption := IntToStr(Value);
2: lblAuto2.Caption := IntToStr(Value);
3: lblAuto3.Caption := IntToStr(Value);
4: lblAuto4.Caption := IntToStr(Value);
5: lblAuto5.Caption := IntToStr(Value);
6: lblAuto6.Caption := IntToStr(Value);
end;
end;
procedure TfrmMain.SetProgress(Idx: Integer; const Value: string);
begin
case Idx of
1: lblAuto1.Caption := IntToStr(FSkill[Idx].Value);
2: lblAuto2.Caption := IntToStr(FSkill[Idx].Value);
3: lblAuto3.Caption := IntToStr(FSkill[Idx].Value);
4: lblAuto4.Caption := IntToStr(FSkill[Idx].Value);
5: lblAuto5.Caption := IntToStr(FSkill[Idx].Value);
6: lblAuto6.Caption := IntToStr(FSkill[Idx].Value);
end;
end;
procedure TfrmMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if FHotKey then
UnregisterHotKey(Handle, 123);
ThreadSearch.Terminate;
ThreadDeal.Terminate;
end;
procedure TfrmMain.FormShow(Sender: TObject);
begin
tryIco.HideTaskbarIcon;
end;
procedure TfrmMain.WMHotKey(var msg: TMessage);
begin
if GameChr.ZtHwnd = 0 then
Exit;
if (msg.LParamHi = VK_END) and (msg.LParamLo = MOD_CONTROL) then
begin
chkStart.Checked := not chkStart.Checked;
SetForegroundWindow(GameChr.ZtHwnd);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -