惠州微网站推广方案,青海培训网站建设公司,网站建设需求 百度文库,东莞建设工程交易中心门户网站最近玩了玩天龙八部#xff0c;玩这个游戏简直就是遭罪#xff0c;升级非常慢#xff0c;而且杀怪也很累#xff0c;纯手工#xff0c;我都不知道为什么还有那么多人玩。玩到40多级了#xff0c;实在是受不了#xff0c;游戏的颜色搭配也是非常的伤眼睛#xff0c;于是… 最近玩了玩天龙八部玩这个游戏简直就是遭罪升级非常慢而且杀怪也很累纯手工我都不知道为什么还有那么多人玩。玩到40多级了实在是受不了游戏的颜色搭配也是非常的伤眼睛于是我就想写一个自动打怪的辅助工具得了。 接下来我就花了1天多的时间写了程序。有自动寻怪、自动加血、自动加蓝、自动释放技能、防外挂答题报警利用Fetion发送短信到手机。有了这个工具后我就可以挂上关掉电脑需要答题的时候就来答一下题。
附上主要代码有需要代码邮件和我联系吧pim263.net unit BackMainFrm;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, Menus, GlobalDefs, StdCtrls;type TNumItem record StartCol: Byte; EndCol: Byte; end; TNumItemAry array of TNumItem; TBackMainForm class(TForm) MainTray: TTrayIcon; TrayMenu: TPopupMenu; SysSetMenuItem: TMenuItem; ExitSysMenuItem: TMenuItem; N4: TMenuItem; TimerFinder: TTimer; procedure ExitSysMenuItemClick(Sender: TObject); procedure SysSetMenuItemClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure TimerFinderTimer(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure MainTrayClick(Sender: TObject); private FSCBitMap: TBitmap; FNumBitMapAry: array[0..9] of TBitmap; FCurGamePos: TPoint; FFightUnixTick: Cardinal; FIsFighting: Boolean; FIsNeedAnswerQT: Boolean; FLastCalcAnswerUnixTick: Cardinal; FLifeCurrent: Integer; FMagicCurrent: Integer; FBBLifeCurrent: Integer; FPressF1UnixTick: Cardinal; FPressF2UnixTick: Cardinal; FPressF3UnixTick: Cardinal; FPressF4UnixTick: Cardinal; procedure CreateNumBitmapAry; procedure LoadNumBitmapAry(const DirPath: string); procedure DestroyNumBitmapAry; private procedure WMHotKey(var Message: TMessage); message WM_HOTKEY; procedure RegisterHotKeys; procedure InitializeLifeAndMagicColor; procedure CalcCurrentPos; procedure CalcFightState; procedure CalcLifeAndMagic; procedure CalcQuestionState; procedure AutoPressMagicKeys; function TranslateWinHotKeyToLocal(HotKeyValue: Cardinal): Word; procedure AnalyseNum(ABitmap: TBitmap; NumAry: TNumItemAry; List: TStringList); procedure GetNumList(BitMap: TBitmap; var NumAry: TNumItemAry); public end; TBeepThread class(TThread) private FBeepSecs: Integer; procedure SyncSendFetionMsg; protected procedure Execute; override; public constructor Create(BeepSecs: Integer); end;procedure SendFetionMsg(const Msg: string);var BackMainForm: TBackMainForm;implementationuses SystemSetFrm, BcConfigMgr, PisConfig, VirtualKeys, FetchWindow, Math, DateUtils;{$R *.dfm}var BeepThread: TBeepThread nil;procedure SendFetionMsg(const Msg: string);begin if FetionWindowHandle 0 then begin ShowWindow(FetionWindowHandle, SW_NORMAL); SetForegroundWindow(FetionWindowHandle); SendMessage(FetionInputHandle, WM_SETTEXT, 0, Integer(PChar(Msg))); Sleep(20); SendMessage(FetionSendBtnHandle, WM_LBUTTONDOWN, MK_LBUTTON, 0); Sleep(10); SendMessage(FetionSendBtnHandle, WM_LBUTTONUP, 0, 0); ShowWindow(FetionWindowHandle, SW_HIDE); end;end;procedure TBackMainForm.GetNumList(BitMap: TBitmap; var NumAry: TNumItemAry); procedure FetchStartCol(var LoopVar: Integer; BackColor: Integer); var J: Integer; begin while (LoopVar BitMap.Width) do begin for J : 0 to BitMap.Height - 1 do begin //如果不是背景 if (BitMap.Canvas.Pixels[LoopVar, J] xor BackColor) 0 then begin Break; end; end; //如果不是背景则找到字符 if J BitMap.Height then Break; Inc(LoopVar); end; end; procedure FetchEndCol(var LoopVar: Integer; BackColor: Integer); var J: Integer; begin while (LoopVar BitMap.Width) do begin for J : 0 to BitMap.Height - 1 do begin //如果是字符 if (BitMap.Canvas.Pixels[LoopVar, J] xor BackColor) 0 then begin Break; end; end; //如果不是字符则找到背景 if J BitMap.Height then Break; Inc(LoopVar); end; end; var I: Integer; BackColor: Integer; StartCol, EndCol: Byte;begin BackColor : BitMap.Canvas.Pixels[0, 0]; I : 0; while I BitMap.Width do begin FetchStartCol(I, BackColor); if I BitMap.Width then Break; StartCol : I; FetchEndCol(I, BackColor); if I BitMap.Width then Break; EndCol : I - 1; SetLength(NumAry, Length(NumAry) 1); NumAry[High(NumAry)].StartCol : StartCol; NumAry[High(NumAry)].EndCol : EndCol; end;end;procedure TBackMainForm.InitializeLifeAndMagicColor;begin if LifeColor 0 then LifeColor : FSCBitMap.Canvas.Pixels[LifeX, LifeY]; if MagicColor 0 then MagicColor : FSCBitMap.Canvas.Pixels[MagicX, MagicY]; BBLifeColor : LifeColor; MonsterLifeColor : LifeColor;end;procedure TBackMainForm.AnalyseNum(ABitmap: TBitmap; NumAry: TNumItemAry; List: TStringList); function SameNum(const NumItem: TNumItem; Num: Integer): Boolean; var J, K: Integer; RealWidth: Integer; RefIsBgColor, IsBgColor: Boolean; LRefBgColor, LBgColor: Integer; begin Result : True; RealWidth : NumItem.EndCol - NumItem.StartCol 1; if RealWidth FNumBitMapAry[Num].Width then RealWidth : FNumBitMapAry[Num].Width; LRefBgColor : FNumBitMapAry[0].Canvas.Pixels[0, 0]; LBgColor : ABitmap.Canvas.Pixels[0,0]; for J : 0 to RealWidth - 1 do begin for K : 0 to 7 do begin RefIsBgColor : FNumBitMapAry[Num].Canvas.Pixels[J, K] LRefBgColor; IsBgColor : ABitmap.Canvas.Pixels[J NumItem.StartCol, K] LBgColor; // 不相同退出 if RefIsBgColor xor IsBgColor True then begin Result : False; Exit; end; end; end; end; function GetStringNum(const NumItem: TNumItem): string; var I: Integer; begin Result : ; for I : 0 to 9 do begin if SameNum(NumItem, I) then begin Result : IntToStr(I); Break; end; end; end;var I: Integer; LNumStr, TmpStr: string;begin LNumStr : ; for I : 0 to High(NumAry) do begin TmpStr : GetStringNum(NumAry[I]); if TmpStr then begin LNumStr : LNumStr TmpStr; end; if I High(NumAry) then begin if (NumAry[I1].StartCol - NumAry[I].EndCol) 8 then begin List.Add(LNumStr); LNumStr : ; end; end; end; List.Add(LNumStr);end;procedure TBackMainForm.AutoPressMagicKeys;begin if PressKeyF1Secs 0 then begin if (DateTimeToUnix(Now) - FPressF1UnixTick) PressKeyF1Secs then begin MonitorKeyPress([], VK_F1); FPressF1UnixTick : DateTimeToUnix(Now); Sleep(10); end; end; if PressKeyF2Secs 0 then begin if (DateTimeToUnix(Now) - FPressF2UnixTick) PressKeyF2Secs then begin MonitorKeyPress([], VK_F2); FPressF2UnixTick : DateTimeToUnix(Now); Sleep(10); end; end; if PressKeyF3Secs 0 then begin if (DateTimeToUnix(Now) - FPressF3UnixTick) PressKeyF3Secs then begin MonitorKeyPress([], VK_F3); FPressF3UnixTick : DateTimeToUnix(Now); Sleep(10); end; end; if PressKeyF4Secs 0 then begin if (DateTimeToUnix(Now) - FPressF4UnixTick) PressKeyF4Secs then begin MonitorKeyPress([], VK_F4); FPressF4UnixTick : DateTimeToUnix(Now); Sleep(10); end; end; end;procedure TBackMainForm.CalcCurrentPos;var LBitMap: TBitmap; NumAry: TNumItemAry; StrList: TStringList;begin LBitMap : TBitmap.Create; StrList : TStringList.Create; try LBitMap.PixelFormat : pf24bit; LBitMap.Width : 80; LBitMap.Height : 8; LBitMap.Canvas.CopyRect(Rect(0, 0, 80, 8), FSCBitMap.Canvas, Rect(FSCBitMap.Width-110, 29, FSCBitMap.Width-30, 37)); GetNumList(LBitMap, NumAry); if Length(NumAry) 0 then Exit; AnalyseNum(LBitMap, NumAry, StrList); FCurGamePos.X : StrToInt(StrList[0]); FCurGamePos.Y : StrToInt(StrList[1]); finally StrList.Free; LBitMap.Free; end;end;procedure TBackMainForm.CalcFightState;begin FIsFighting : FSCBitMap.Canvas.Pixels[MonsterLifeX, MonsterLifeY] MonsterLifeColor;end;procedure TBackMainForm.CalcLifeAndMagic;var I: Integer;begin // 初始化数据 InitializeLifeAndMagicColor; // 计算生命 I : 0; FLifeCurrent : 0; while True do begin if GetRValue(FSCBitMap.Canvas.Pixels[LifeXI, LifeY]) GetRValue(LifeColor) then Break; Inc(I); Inc(FLifeCurrent); end; // 计算魔法 I : 0; FMagicCurrent : 0; while True do begin if GetBValue(FSCBitMap.Canvas.Pixels[MagicXI, MagicY]) GetBValue(MagicColor) then Break; Inc(I); Inc(FMagicCurrent); end; // 计算宝宝生命 I : 0; FBBLifeCurrent : 0; while True do begin if GetRValue(FSCBitMap.Canvas.Pixels[BBLifeXI, BBLifeY]) GetRValue(BBLifeColor) then Break; Inc(I); Inc(FBBLifeCurrent); end;end;procedure TBackMainForm.CalcQuestionState; // 判断颜色是否有效 function IsValidPoint(X, Y: Integer): Boolean; var AColor: TColor; begin AColor : FSCBitMap.Canvas.Pixels[X, Y]; Result : True; Result : Result and (GetRValue(AColor) GetRValue(QT_MIN_COLOR)); Result : Result and (GetGValue(AColor) GetGValue(QT_MIN_COLOR)); Result : Result and (GetBValue(AColor) GetBValue(QT_MIN_COLOR)); end; // 判断是否是问题窗口 function IsValidQuestion(X, Y: Integer): Boolean; begin Result : True; Result : Result and IsValidPoint(XQT_WIDTH, Y); Result : Result and IsValidPoint(X, YQT_HEIGHT); Result : Result and IsValidPoint(XQT_WIDTH, YQT_HEIGHT); end;var I, J: Integer;begin if (DateTimeToUnix(Now) - FLastCalcAnswerUnixTick) 5 then Exit; // 记录最后计算时间 FLastCalcAnswerUnixTick : DateTimeToUnix(Now); FIsNeedAnswerQT : False; for I : 0 to (FSCBitMap.Width div 2) - 1 do begin for J : 0 to (FSCBitMap.Height div 2) - 1 do begin if IsValidPoint(I, J) then begin if IsValidQuestion(I, J) then begin FIsNeedAnswerQT : True; Exit; end; end; end; end;end;procedure TBackMainForm.CreateNumBitmapAry;var I: Integer;begin for I : 0 to 9 do begin FNumBitMapAry[I] : TBitmap.Create; FNumBitMapAry[I].PixelFormat : pf24bit; end;end;procedure TBackMainForm.DestroyNumBitmapAry;var I: Integer;begin for I : 0 to 9 do begin FNumBitMapAry[I].Free; end;end;procedure TBackMainForm.ExitSysMenuItemClick(Sender: TObject);begin if Application.MessageBox(确实要退出?, 提示信息, MB_YESNO MB_ICONQUESTION) mrYes then begin Application.Terminate; end;end;procedure TBackMainForm.FormCreate(Sender: TObject); procedure LoadConfig; begin FetionWindowIncText : ConfigMgr.FetionWindowText; FetionWindowHandle : ConfigMgr.FetionWindowHandle; FetionInputHandle : ConfigMgr.FetionInputWindowHandle; FetionSendBtnHandle : ConfigMgr.FetionSendBtnWindowHandle; end;begin FSCBitMap : TBitmap.Create; FFightUnixTick : 0; Randomize; MainTray.Hint : 天龙八部自助打怪 1.0; LoadConfig; CreateNumBitmapAry; LoadNumBitmapAry(./DigitalImages/); RegisterHotKeys; FCurGamePos.X : 0; FCurGamePos.Y : 0; TimerFinder.Interval : FinderTimerMSec;end;procedure TBackMainForm.FormDestroy(Sender: TObject);begin FSCBitMap.Free; DestroyNumBitmapAry;end;procedure TBackMainForm.LoadNumBitmapAry(const DirPath: string);var I: Integer;begin for I : 0 to 9 do begin FNumBitMapAry[I].LoadFromFile(Format(%s%d.bmp, [DirPath, I])); end;end;procedure TBackMainForm.MainTrayClick(Sender: TObject);begin BackMainForm.Show;end;procedure TBackMainForm.RegisterHotKeys;var GlobalId: Word; AModifiers: Cardinal;begin AModifiers : MOD_CONTROL MOD_ALT;; // 开关 CTRL ALT F10 GlobalId : GlobalAddAtom(PChar(HotKey_TLBBHelperF10)); RegisterHotKey(Self.Handle, GlobalId, AModifiers, VK_F10); // 设定原点 CTRL ALT F11 GlobalId : GlobalAddAtom(PChar(HotKey_TLBBHelperF11)); RegisterHotKey(Self.Handle, GlobalId, AModifiers, VK_F11); // 调出设定对话框 CTRL ALT F12 GlobalId : GlobalAddAtom(PChar(HotKey_TLBBHelperF12)); RegisterHotKey(Self.Handle, GlobalId, AModifiers, VK_F12); // 终止发送报警消息线程 CTRL ALT F1 GlobalId : GlobalAddAtom(PChar(HotKey_TLBBHelperF1)); RegisterHotKey(Self.Handle, GlobalId, AModifiers, VK_F1); // 发送Fetion测试包 CTRL ALT F1 GlobalId : GlobalAddAtom(PChar(HotKey_TLBBHelperF2)); RegisterHotKey(Self.Handle, GlobalId, AModifiers, VK_F2); end;procedure TBackMainForm.SysSetMenuItemClick(Sender: TObject);var OldState: Boolean;begin if TSystemSetForm.IsExist then Exit; OldState : TimerFinder.Enabled; TimerFinder.Enabled : False; with TSystemSetForm.Create(Self) do try if ShowModal mrOk then begin TimerFinder.Interval : FinderTimerMSec; end; finally Free; end; TimerFinder.Enabled : OldState;end;procedure TBackMainForm.TimerFinderTimer(Sender: TObject); procedure RandomFinderMonster; var X, Y: Integer; begin if FCurGamePos.X CenterPosX then X : RandomRange(FinderMinX, FinderMaxX) else X : RandomRange(-FinderMaxX, -FinderMinX); if FCurGamePos.Y CenterPosY then Y : RandomRange(FinderMinY, FinderMaxY) else Y : RandomRange(-FinderMaxY, -FinderMinY); X : Screen.Width div 2 X; Y : Screen.Height div 2 Y; MonitorMouseMove(X, Y); Sleep(10); end; procedure FindMonster; begin // 寻找怪物 if not FIsFighting then begin FFightUnixTick : 0; RandomFinderMonster; MonitorMouseClick(1); end else begin if FFightUnixTick 0 then FFightUnixTick : DateTimeToUnix(Now) else begin // 如果找怪超时则重新寻找 if DateTimeToUnix(Now) - FFightUnixTick 15 then begin // 随机移动位置(必须执行此操作否则会死锁) MonitorMouseMove(RandomRange(0, Screen.Width div 2), RandomRange(0, Screen.Height div 2)); Sleep(10); MonitorMouseClick(2); end else begin // 释放魔法 AutoPressMagicKeys; end; end; end; end; procedure FillLifeAndMagic; begin // 补人物血 if ((FLifeCurrent*100) div LIFE_MAX) LifeMin then begin MonitorKeyPress([], KeyLifeAdd); end; Sleep(20); // 补宝宝血 if ((FBBLifeCurrent*100) div BB_LIFE_MAX) BBLifeMin then begin MonitorKeyPress([], KeyBBLifeAdd); end; Sleep(20); // 补任务魔法 if ((FMagicCurrent*100) div MAGIC_MAX) MagicMin then begin MonitorKeyPress([], KeyMagicAdd); end; end; procedure PickGoods; begin // 一定要在没有打怪状态 if not FIsFighting then begin RandomFinderMonster; MonitorMouseClick(2); Sleep(10); end; end;begin try FetchWindowImage(FSCBitMap); CalcFightState; CalcCurrentPos; CalcQuestionState; CalcLifeAndMagic; //PickGoods;(暂时不开启有问题) FindMonster; Sleep(20); FillLifeAndMagic; // 启动报警程序 if FIsNeedAnswerQT and (BeepThread nil) then TBeepThread.Create(50).Resume; except end;end;function TBackMainForm.TranslateWinHotKeyToLocal( HotKeyValue: Cardinal): Word;var ALWord, AHWord: Word;begin Result : 0; AHWord : HiWord(HotKeyValue); ALWord : HotKeyValue and $FFFF; if ALWord and MOD_SHIFT 0 then Result : Result scShift; if ALWord and MOD_ALT 0 then Result : Result scAlt; if ALWord and MOD_CONTROL 0 then Result : Result scCtrl; Result : Result AHWord;end;procedure TBackMainForm.WMHotKey(var Message: TMessage);var LocalKey: Word;begin LocalKey : TranslateWinHotKeyToLocal(Message.LParam); if LocalKey scCtrl scAlt VK_F10 then begin // 系统开关 TimerFinder.Enabled : not TimerFinder.Enabled; Windows.Beep(3000, 100); end else if LocalKey scCtrl scAlt VK_F11 then begin // 设置原点 FetchWindowImage(FSCBitMap); CalcCurrentPos; CenterPosX : FCurGamePos.X; CenterPosY : FCurGamePos.Y; Windows.Beep(2000, 100); Windows.Beep(2500, 100); end else if LocalKey scCtrl scAlt VK_F12 then begin // 调出设置框 SysSetMenuItemClick(nil); end else if LocalKey scCtrl scAlt VK_F1 then begin // 关闭线程 try if Assigned(BeepThread) then begin BeepThread.Terminate; end; except end; end else if LocalKey scCtrl scAlt VK_F2 then begin SendFetionMsg(天龙八部助手测试!); end;end;{ TBeepThread }constructor TBeepThread.Create(BeepSecs: Integer);begin inherited Create(True); FreeOnTerminate : True; FBeepSecs : BeepSecs; // 记录自己 BeepThread : Self;end;procedure TBeepThread.Execute;var StartUnixTick: Cardinal;begin StartUnixTick : DateTimeToUnix(Now); SyncSendFetionMsg; while not Terminated do begin if DateTimeToUnix(now) - StartUnixTick FBeepSecs then Break; Windows.Beep(4000, 300); Sleep(700); end; BeepThread : nil;end;procedure TBeepThread.SyncSendFetionMsg;begin SendFetionMsg(TLBBHelper: 需要输入验证码!);end;end. unit GlobalDefs;interfaceuses Windows;{ 相关配置参数 }const LIFE_MAX 124; MAGIC_MAX 124; BB_LIFE_MAX 96; QT_MIN_COLOR $FAFAFA; QT_WIDTH 237; QT_HEIGHT 298;var FinderTimerMSec: Integer 200; // 系统Timer执行时间 LifeX: Integer 64; // 人物生命值X坐标 LifeY: Integer 32; // 人物生命值Y坐标 LifeColor: Integer 0; // 人物生命值取样颜色(加载时初始化) LifeMin: Integer 50; // 人物生命最小百分比 MagicX: Integer 64; // 人物魔法值X坐标 MagicY: Integer 38; // 人物魔法值Y坐标 MagicColor: Integer 0; // 人物魔法值取样颜色(加载时初始化) MagicMin: Integer 50; // 人物魔法最小百分比 BBLifeX: Integer 91; // 宝宝生命值X坐标 BBLifeY: Integer 71; // 宝宝生命值Y坐标 BBLifeColor: Integer 0; // 宝宝生命值取样颜色(加载时初始化) BBLifeMin: Integer 30; // 宝宝生命最小百分比 MonsterLifeX: Integer 247; // 怪物生命值X坐标 MonsterLifeY: Integer 32; // 怪物生命值Y坐标 MonsterLifeColor: Integer 0; // 怪物生命值取样颜色(加载时初始化) CenterPosX: Integer 185; // 自动打怪中心位置X坐标 CenterPosY: Integer 215; // 自动打怪中心位置Y坐标 FinderMaxX: Integer 100; // 自动打怪寻怪X轴距离最大值 FinderMinX: Integer 30; // 自动打怪寻怪X轴距离最小值 FinderMaxY: Integer 100; // 自动打怪寻怪Y轴距离最大值 FinderMinY: Integer 30; // 自动打怪寻怪Y轴距离最小值 AvgKillMonsterSecs: Integer 15; // 平均每个怪的打怪时间(校正用) KeyLifeAdd: Word VK_F8; // 人物加血键 KeyMagicAdd: Word VK_F9; // 人物加魔法键 KeyBBLifeAdd: Word VK_F10; // 宝宝加血键 PressKeyF1Secs: Integer 10; // 自动按F1键时间间隔 PressKeyF2Secs: Integer 15; // 自动按F2键时间间隔 PressKeyF3Secs: Integer 40; // 自动按F3键时间间隔 PressKeyF4Secs: Integer 0; // 自动按F4键时间间隔 FetionWindowHandle: Integer 0; FetionWindowIncText: string --; FetionInputHandle: Integer 0; FetionSendBtnHandle: Integer 0;implementationend.