1. 程式人生 > >研究天龍八部(網遊), 寫了個輔助自動打怪、答題提示的輔助工具

研究天龍八部(網遊), 寫了個輔助自動打怪、答題提示的輔助工具

  最近玩了玩天龍八部,玩這個遊戲簡直就是遭罪,升級非常慢,而且殺怪也很累,純手工,我都不知道為什麼還有那麼多人玩。玩到40多級了,實在是受不了,遊戲的顏色搭配也是非常的傷眼睛,於是我就想寫一個自動打怪的輔助工具得了。

  接下來我就花了1天多的時間寫了程式。有自動尋怪、自動加血、自動加藍、自動釋放技能、防外掛答題報警(利用Fetion傳送簡訊到手機)。有了這個工具後我就可以掛上,關掉電腦,需要答題的時候就來答一下題。

附上主要程式碼(有需要程式碼郵件和我聯絡吧:[email protected]):

  1. unit BackMainFrm;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, ExtCtrls, Menus, GlobalDefs, StdCtrls;
  6. type
  7.   TNumItem = record
  8.     StartCol: Byte;
  9.     EndCol: Byte;
  10. end;
  11.   TNumItemAry = arrayof TNumItem;
  12.   TBackMainForm = class(TForm)
  13.     MainTray: TTrayIcon;
  14.     TrayMenu: TPopupMenu;
  15.     SysSetMenuItem: TMenuItem;
  16.     ExitSysMenuItem: TMenuItem;
  17.     N4: TMenuItem;
  18.     TimerFinder: TTimer;
  19. procedure ExitSysMenuItemClick(Sender: TObject);
  20. procedure SysSetMenuItemClick(Sender: TObject);
  21. procedure FormCreate(Sender: TObject);
  22. procedure TimerFinderTimer(Sender: TObject);
  23. procedure FormDestroy(Sender: TObject);
  24. procedure MainTrayClick(Sender: TObject);
  25. private
  26.     FSCBitMap: TBitmap;
  27.     FNumBitMapAry: array[0..9of TBitmap;
  28.     FCurGamePos: TPoint;
  29.     FFightUnixTick: Cardinal;
  30.     FIsFighting: Boolean;
  31.     FIsNeedAnswerQT: Boolean;
  32.     FLastCalcAnswerUnixTick: Cardinal;
  33.     FLifeCurrent: Integer;
  34.     FMagicCurrent: Integer;
  35.     FBBLifeCurrent: Integer;
  36.     FPressF1UnixTick: Cardinal;
  37.     FPressF2UnixTick: Cardinal;
  38.     FPressF3UnixTick: Cardinal;
  39.     FPressF4UnixTick: Cardinal;
  40. procedure CreateNumBitmapAry;
  41. procedure LoadNumBitmapAry(const DirPath: string);
  42. procedure DestroyNumBitmapAry;
  43. private
  44. procedure WMHotKey(var Message: TMessage); message WM_HOTKEY;
  45. procedure RegisterHotKeys;
  46. procedure InitializeLifeAndMagicColor;
  47. procedure CalcCurrentPos;
  48. procedure CalcFightState;
  49. procedure CalcLifeAndMagic;
  50. procedure CalcQuestionState;
  51. procedure AutoPressMagicKeys;
  52. function TranslateWinHotKeyToLocal(HotKeyValue: Cardinal): Word;
  53. procedure AnalyseNum(ABitmap: TBitmap; NumAry: TNumItemAry; List: TStringList);
  54. procedure GetNumList(BitMap: TBitmap; var NumAry: TNumItemAry);
  55. public
  56. end;
  57.   TBeepThread = class(TThread)
  58. private
  59.     FBeepSecs: Integer;
  60. procedure SyncSendFetionMsg;
  61. protected
  62. procedure Execute; override;
  63. public
  64. constructor Create(BeepSecs: Integer);
  65. end;
  66. procedure SendFetionMsg(const Msg: string);
  67. var
  68.   BackMainForm: TBackMainForm;
  69. implementation
  70. uses SystemSetFrm, BcConfigMgr, PisConfig, VirtualKeys, FetchWindow, Math,
  71.   DateUtils;
  72. {$R *.dfm}
  73. var
  74.   BeepThread: TBeepThread = nil;
  75. procedure SendFetionMsg(const Msg: string);
  76. begin
  77. if FetionWindowHandle <> 0then
  78. begin
  79.     ShowWindow(FetionWindowHandle, SW_NORMAL);
  80.     SetForegroundWindow(FetionWindowHandle);
  81.     SendMessage(FetionInputHandle, WM_SETTEXT, 0, Integer(PChar(Msg)));
  82.     Sleep(20);
  83.     SendMessage(FetionSendBtnHandle, WM_LBUTTONDOWN, MK_LBUTTON, 0);
  84.     Sleep(10);
  85.     SendMessage(FetionSendBtnHandle, WM_LBUTTONUP, 00);
  86.     ShowWindow(FetionWindowHandle, SW_HIDE);
  87. end;
  88. end;
  89. procedure TBackMainForm.GetNumList(BitMap: TBitmap; var NumAry: TNumItemAry);
  90. procedure FetchStartCol(var LoopVar: Integer; BackColor: Integer);
  91. var
  92.     J: Integer;
  93. begin
  94. while (LoopVar < BitMap.Width) do
  95. begin
  96. for J := 0to BitMap.Height - 1do
  97. begin
  98. //如果不是背景
  99. if (BitMap.Canvas.Pixels[LoopVar, J] xor BackColor) <> 0then
  100. begin
  101.           Break;
  102. end;
  103. end;
  104. //如果不是背景,則找到字元
  105. if J < BitMap.Height then
  106.         Break;
  107.       Inc(LoopVar);
  108. end;
  109. end;
  110. procedure FetchEndCol(var LoopVar: Integer; BackColor: Integer);
  111. var
  112.     J: Integer;
  113. begin
  114. while (LoopVar < BitMap.Width) do
  115. begin
  116. for J := 0to BitMap.Height - 1do
  117. begin
  118. //如果是字元
  119. if (BitMap.Canvas.Pixels[LoopVar, J] xor BackColor) <> 0then
  120. begin
  121.           Break;
  122. end;
  123. end;
  124. //如果不是字元,則找到背景
  125. if J >= BitMap.Height then
  126.         Break;
  127.       Inc(LoopVar);
  128. end;
  129. end;
  130. var
  131.   I: Integer;
  132.   BackColor: Integer;
  133.   StartCol, EndCol: Byte;
  134. begin
  135.   BackColor := BitMap.Canvas.Pixels[00];
  136.   I := 0;
  137. while I < BitMap.Width do
  138. begin
  139.     FetchStartCol(I, BackColor);
  140. if I >= BitMap.Width then
  141.       Break;
  142.     StartCol := I;
  143.     FetchEndCol(I, BackColor);
  144. if I >= BitMap.Width then
  145.       Break;
  146.     EndCol := I - 1;
  147.     SetLength(NumAry, Length(NumAry) + 1);
  148.     NumAry[High(NumAry)].StartCol := StartCol;
  149.     NumAry[High(NumAry)].EndCol := EndCol;
  150. end;
  151. end;
  152. procedure TBackMainForm.InitializeLifeAndMagicColor;
  153. begin
  154. if LifeColor = 0then
  155.     LifeColor := FSCBitMap.Canvas.Pixels[LifeX, LifeY];
  156. if MagicColor = 0then
  157.     MagicColor := FSCBitMap.Canvas.Pixels[MagicX, MagicY];
  158.   BBLifeColor := LifeColor;
  159.   MonsterLifeColor := LifeColor;
  160. end;
  161. procedure TBackMainForm.AnalyseNum(ABitmap: TBitmap; NumAry: TNumItemAry;
  162.   List: TStringList);
  163. function SameNum(const NumItem: TNumItem; Num: Integer): Boolean;
  164. var
  165.     J, K: Integer;
  166.     RealWidth: Integer;
  167.     RefIsBgColor, IsBgColor: Boolean;
  168.     LRefBgColor, LBgColor: Integer;
  169. begin
  170.     Result := True;
  171.     RealWidth := NumItem.EndCol - NumItem.StartCol + 1;
  172. if RealWidth > FNumBitMapAry[Num].Width then
  173.       RealWidth := FNumBitMapAry[Num].Width;
  174.     LRefBgColor := FNumBitMapAry[0].Canvas.Pixels[00];
  175.     LBgColor := ABitmap.Canvas.Pixels[0,0];
  176. for J := 0to RealWidth - 1do
  177. begin
  178. for K := 0to7do
  179. begin
  180.         RefIsBgColor := FNumBitMapAry[Num].Canvas.Pixels[J, K] = LRefBgColor;
  181.         IsBgColor := ABitmap.Canvas.Pixels[J + NumItem.StartCol, K] = LBgColor;
  182. // 不相同退出
  183. if RefIsBgColor xor IsBgColor = True then
  184. begin
  185.           Result := False;
  186.           Exit;
  187. end;
  188. end;
  189. end;
  190. end;
  191. function GetStringNum(const NumItem: TNumItem): string;
  192. var
  193.     I: Integer;
  194. begin
  195.     Result := '';
  196. for I := 0to9do
  197. begin
  198. if SameNum(NumItem, I) then
  199. begin
  200.         Result := IntToStr(I);
  201.         Break;
  202. end;
  203. end;
  204. end;
  205. var
  206.   I: Integer;
  207.   LNumStr, TmpStr: string;
  208. begin
  209.   LNumStr := '';
  210. for I := 0to High(NumAry) do
  211. begin
  212.     TmpStr := GetStringNum(NumAry[I]);
  213. if TmpStr <> ''then
  214. begin
  215.       LNumStr := LNumStr + TmpStr;
  216. end;
  217. if I < High(NumAry) then
  218. begin
  219. if (NumAry[I+1].StartCol - NumAry[I].EndCol) > 8then
  220. begin
  221.         List.Add(LNumStr);
  222.         LNumStr := '';
  223. end;
  224. end;
  225. end;
  226.   List.Add(LNumStr);
  227. end;
  228. procedure TBackMainForm.AutoPressMagicKeys;
  229. begin
  230. if PressKeyF1Secs <> 0then
  231. begin
  232. if (DateTimeToUnix(Now) - FPressF1UnixTick) > PressKeyF1Secs then
  233. begin
  234.       MonitorKeyPress([], VK_F1);
  235.       FPressF1UnixTick := DateTimeToUnix(Now);
  236.       Sleep(10);
  237. end;
  238. end;
  239. if PressKeyF2Secs <> 0then
  240. begin
  241. if (DateTimeToUnix(Now) - FPressF2UnixTick) > PressKeyF2Secs then
  242. begin
  243.       MonitorKeyPress([], VK_F2);
  244.       FPressF2UnixTick := DateTimeToUnix(Now);
  245.       Sleep(10);
  246. end;
  247. end;
  248. if PressKeyF3Secs <> 0then
  249. begin
  250. if (DateTimeToUnix(Now) - FPressF3UnixTick) > PressKeyF3Secs then
  251. begin
  252.       MonitorKeyPress([], VK_F3);
  253.       FPressF3UnixTick := DateTimeToUnix(Now);
  254.       Sleep(10);
  255. end;
  256. end;
  257. if PressKeyF4Secs <> 0then
  258. begin
  259. if (DateTimeToUnix(Now) - FPressF4UnixTick) > PressKeyF4Secs then
  260. begin
  261.       MonitorKeyPress([], VK_F4);
  262.       FPressF4UnixTick := DateTimeToUnix(Now);
  263.       Sleep(10);
  264. end;
  265. end;    
  266. end;
  267. procedure TBackMainForm.CalcCurrentPos;
  268. var
  269.   LBitMap: TBitmap;
  270.   NumAry: TNumItemAry;
  271.   StrList: TStringList;
  272. begin
  273.   LBitMap := TBitmap.Create;
  274.   StrList := TStringList.Create;
  275. try
  276.     LBitMap.PixelFormat := pf24bit;
  277.     LBitMap.Width := 80;
  278.     LBitMap.Height := 8;
  279.     LBitMap.Canvas.CopyRect(Rect(00808), FSCBitMap.Canvas,
  280.       Rect(FSCBitMap.Width-11029, FSCBitMap.Width-3037));
  281.     GetNumList(LBitMap, NumAry);
  282. if Length(NumAry) <= 0then
  283.       Exit;
  284.     AnalyseNum(LBitMap, NumAry, StrList);
  285.     FCurGamePos.X := StrToInt(StrList[0]);
  286.     FCurGamePos.Y := StrToInt(StrList[1]);
  287. finally
  288.     StrList.Free;
  289.     LBitMap.Free;
  290. end;
  291. end;
  292. procedure TBackMainForm.CalcFightState;
  293. begin
  294.   FIsFighting :=
  295.     FSCBitMap.Canvas.Pixels[MonsterLifeX, MonsterLifeY] = MonsterLifeColor;
  296. end;
  297. procedure TBackMainForm.CalcLifeAndMagic;
  298. var
  299.   I: Integer;
  300. begin
  301. // 初始化資料
  302.   InitializeLifeAndMagicColor;
  303. // 計算生命
  304.   I := 0;
  305.   FLifeCurrent := 0;
  306. while True do
  307. begin
  308. if GetRValue(FSCBitMap.Canvas.Pixels[LifeX+I, LifeY]) <> GetRValue(LifeColor) then
  309.       Break;
  310.     Inc(I);
  311.     Inc(FLifeCurrent);
  312. end;
  313. // 計算魔法
  314.   I := 0;
  315.   FMagicCurrent := 0;
  316. while True do
  317. begin
  318. if GetBValue(FSCBitMap.Canvas.Pixels[MagicX+I, MagicY]) <> GetBValue(MagicColor) then
  319.       Break;
  320.     Inc(I);
  321.     Inc(FMagicCurrent);
  322. end;
  323. // 計算寶寶生命
  324.   I := 0;
  325.   FBBLifeCurrent := 0;
  326. while True do
  327. begin
  328. if GetRValue(FSCBitMap.Canvas.Pixels[BBLifeX+I, BBLifeY]) <> GetRValue(BBLifeColor) then
  329.       Break;
  330.     Inc(I);
  331.     Inc(FBBLifeCurrent);
  332. end;
  333. end;
  334. procedure TBackMainForm.CalcQuestionState;
  335. // 判斷顏色是否有效
  336. function IsValidPoint(X, Y: Integer): Boolean;
  337. var
  338.     AColor: TColor;
  339. begin
  340.     AColor := FSCBitMap.Canvas.Pixels[X, Y];
  341.     Result := True;
  342.     Result := Result and (GetRValue(AColor) >= GetRValue(QT_MIN_COLOR));
  343.     Result := Result and (GetGValue(AColor) >= GetGValue(QT_MIN_COLOR));
  344.     Result := Result and (GetBValue(AColor) >= GetBValue(QT_MIN_COLOR));
  345. end;
  346. // 判斷是否是問題視窗
  347. function IsValidQuestion(X, Y: Integer): Boolean;
  348. begin
  349.     Result := True;
  350.     Result := Result and IsValidPoint(X+QT_WIDTH, Y);
  351.     Result := Result and IsValidPoint(X, Y+QT_HEIGHT);
  352.     Result := Result and IsValidPoint(X+QT_WIDTH, Y+QT_HEIGHT);
  353. end;
  354. var
  355.   I, J: Integer;
  356. begin
  357. if (DateTimeToUnix(Now) - FLastCalcAnswerUnixTick) < 5then
  358.     Exit;
  359. // 記錄最後計算時間
  360.   FLastCalcAnswerUnixTick := DateTimeToUnix(Now);
  361.   FIsNeedAnswerQT := False;
  362. for I := 0to (FSCBitMap.Width div2) - 1do
  363. begin
  364. for J := 0to (FSCBitMap.Height div2) - 1do
  365. begin
  366. if IsValidPoint(I, J) then
  367. begin
  368. if IsValidQuestion(I, J) then
  369. begin
  370.           FIsNeedAnswerQT := True;
  371.           Exit;
  372. end;
  373. end;
  374. end;
  375. end;
  376. end;
  377. procedure TBackMainForm.CreateNumBitmapAry;
  378. var
  379.   I: Integer;
  380. begin
  381. for I := 0to9do
  382. begin
  383.     FNumBitMapAry[I] := TBitmap.Create;
  384.     FNumBitMapAry[I].PixelFormat := pf24bit;
  385. end;
  386. end;
  387. procedure TBackMainForm.DestroyNumBitmapAry;
  388. var
  389.   I: Integer;
  390. begin
  391. for I := 0to9do
  392. begin
  393.     FNumBitMapAry[I].Free;
  394. end;
  395. end;
  396. procedure TBackMainForm.ExitSysMenuItemClick(Sender: TObject);
  397. begin
  398. if Application.MessageBox('確實要退出?''提示資訊',
  399.     MB_YESNO + MB_ICONQUESTION) = mrYes  then
  400. begin
  401.     Application.Terminate;
  402. end;
  403. end;
  404. procedure TBackMainForm.FormCreate(Sender: TObject);
  405. procedure LoadConfig;
  406. begin
  407.     FetionWindowIncText := ConfigMgr.FetionWindowText;
  408.     FetionWindowHandle := ConfigMgr.FetionWindowHandle;
  409.     FetionInputHandle := ConfigMgr.FetionInputWindowHandle;
  410.     FetionSendBtnHandle := ConfigMgr.FetionSendBtnWindowHandle;
  411. end;
  412. begin
  413.   FSCBitMap := TBitmap.Create;
  414.   FFightUnixTick := 0;
  415.   Randomize;
  416.   MainTray.Hint := '天龍八部自助打怪 1.0';
  417.   LoadConfig;
  418.   CreateNumBitmapAry;
  419.   LoadNumBitmapAry('./DigitalImages/');
  420.   RegisterHotKeys;
  421.   FCurGamePos.X := 0;
  422.   FCurGamePos.Y := 0;
  423.   TimerFinder.Interval := FinderTimerMSec;
  424. end;
  425. procedure TBackMainForm.FormDestroy(Sender: TObject);
  426. begin
  427.   FSCBitMap.Free;
  428.   DestroyNumBitmapAry;
  429. end;
  430. procedure TBackMainForm.LoadNumBitmapAry(const DirPath: string);
  431. var
  432.   I: Integer;
  433. begin
  434. for I := 0to9do
  435. begin
  436.     FNumBitMapAry[I].LoadFromFile(Format('%s%d.bmp', [DirPath, I]));
  437. end;
  438. end;
  439. procedure TBackMainForm.MainTrayClick(Sender: TObject);
  440. begin
  441.   BackMainForm.Show;
  442. end;
  443. procedure TBackMainForm.RegisterHotKeys;
  444. var
  445.   GlobalId: Word;
  446.   AModifiers: Cardinal;
  447. begin
  448.   AModifiers := MOD_CONTROL + MOD_ALT;;
  449. // 開關 CTRL + ALT + F10
  450.   GlobalId := GlobalAddAtom(PChar('HotKey_TLBBHelperF10'));
  451.   RegisterHotKey(Self.Handle, GlobalId, AModifiers, VK_F10);
  452. // 設定原點 CTRL + ALT + F11
  453.   GlobalId := GlobalAddAtom(PChar('HotKey_TLBBHelperF11'));
  454.   RegisterHotKey(Self.Handle, GlobalId, AModifiers, VK_F11);
  455. // 調出設定對話方塊 CTRL + ALT + F12
  456.   GlobalId := GlobalAddAtom(PChar('HotKey_TLBBHelperF12'));
  457.   RegisterHotKey(Self.Handle, GlobalId, AModifiers, VK_F12);
  458. // 終止傳送報警訊息執行緒 CTRL + ALT + F1
  459.   GlobalId := GlobalAddAtom(PChar('HotKey_TLBBHelperF1'));
  460.   RegisterHotKey(Self.Handle, GlobalId, AModifiers, VK_F1);
  461. // 傳送Fetion測試包 CTRL + ALT + F1
  462.   GlobalId := GlobalAddAtom(PChar('HotKey_TLBBHelperF2'));
  463.   RegisterHotKey(Self.Handle, GlobalId, AModifiers, VK_F2);  
  464. end;
  465. procedure TBackMainForm.SysSetMenuItemClick(Sender: TObject);
  466. var
  467.   OldState: Boolean;
  468. begin
  469. if TSystemSetForm.IsExist then Exit;
  470.   OldState := TimerFinder.Enabled;
  471.   TimerFinder.Enabled := False;
  472. with TSystemSetForm.Create(Self) do
  473. try
  474. if ShowModal = mrOk then
  475. begin
  476.       TimerFinder.Interval := FinderTimerMSec;
  477. end;
  478. finally
  479.     Free;
  480. end;
  481.   TimerFinder.Enabled := OldState;
  482. end;
  483. procedure TBackMainForm.TimerFinderTimer(Sender: TObject);
  484. procedure RandomFinderMonster;
  485. var
  486.     X, Y: Integer;
  487. begin
  488. if FCurGamePos.X < CenterPosX then
  489.       X := RandomRange(FinderMinX, FinderMaxX)
  490. else
  491.       X := RandomRange(-FinderMaxX, -FinderMinX);
  492. if FCurGamePos.Y < CenterPosY then
  493.       Y := RandomRange(FinderMinY, FinderMaxY)
  494. else
  495.       Y := RandomRange(-FinderMaxY, -FinderMinY);
  496.     X := Screen.Width div2 + X;
  497.     Y := Screen.Height div2 + Y;
  498.     MonitorMouseMove(X, Y);
  499.     Sleep(10);
  500. end;
  501. procedure FindMonster;
  502. begin
  503. // 尋找怪物
  504. ifnot FIsFighting then
  505. begin
  506.       FFightUnixTick := 0;
  507.       RandomFinderMonster;
  508.       MonitorMouseClick(1);
  509. endelse
  510. begin
  511. if FFightUnixTick  = 0then
  512.         FFightUnixTick := DateTimeToUnix(Now)
  513. else
  514. begin
  515. // 如果找怪超時,則重新尋找
  516. if DateTimeToUnix(Now) - FFightUnixTick > 15then
  517. begin
  518. // 隨機移動位置(必須執行此操作,否則會死鎖)
  519.           MonitorMouseMove(RandomRange(0, Screen.Width div2),
  520.             RandomRange(0, Screen.Height div2));
  521.           Sleep(10);
  522.           MonitorMouseClick(2);
  523. endelse
  524. begin
  525. // 釋放魔法
  526.           AutoPressMagicKeys;
  527. end;
  528. end;
  529. end;
  530. end;
  531. procedure FillLifeAndMagic;
  532. begin
  533. // 補人物血
  534. if ((FLifeCurrent*100div LIFE_MAX) <= LifeMin then
  535. begin
  536.       MonitorKeyPress([], KeyLifeAdd);
  537. end;
  538.     Sleep(20);
  539. // 補寶寶血
  540. if ((FBBLifeCurrent*100div BB_LIFE_MAX) <= BBLifeMin then
  541. begin
  542.       MonitorKeyPress([], KeyBBLifeAdd);
  543. end;
  544.     Sleep(20);
  545. // 補任務魔法
  546. if ((FMagicCurrent*100div MAGIC_MAX) <= MagicMin then
  547. begin
  548.       MonitorKeyPress([], KeyMagicAdd);
  549. end;
  550. end;
  551. procedure PickGoods;
  552. begin
  553. // 一定要在沒有打怪狀態
  554. ifnot FIsFighting then
  555. begin
  556.       RandomFinderMonster;
  557.       MonitorMouseClick(2);
  558.       Sleep(10);
  559. end;
  560. end;
  561. begin
  562. try
  563.     FetchWindowImage(FSCBitMap);
  564.     CalcFightState;
  565.     CalcCurrentPos;
  566.     CalcQuestionState;
  567.     CalcLifeAndMagic;
  568. //PickGoods;(暫時不開啟,有問題)
  569.     FindMonster;
  570.     Sleep(20);
  571.     FillLifeAndMagic;
  572. // 啟動報警程式
  573. if FIsNeedAnswerQT and (BeepThread = nilthen
  574.       TBeepThread.Create(50).Resume;
  575. except
  576. end;
  577. end;
  578. function TBackMainForm.TranslateWinHotKeyToLocal(
  579.   HotKeyValue: Cardinal): Word;
  580. var
  581.   ALWord, AHWord: Word;
  582. begin
  583.   Result := 0;
  584.   AHWord := HiWord(HotKeyValue);
  585.   ALWord := HotKeyValue and$FFFF;
  586. if ALWord and MOD_SHIFT <> 0then
  587.     Result := Result + scShift;
  588. if ALWord and MOD_ALT <> 0then
  589.     Result := Result + scAlt;
  590. if ALWord and MOD_CONTROL <> 0then
  591.     Result := Result + scCtrl;
  592.   Result := Result + AHWord;
  593. end;
  594. procedure TBackMainForm.WMHotKey(var Message: TMessage);
  595. var
  596.   LocalKey: Word;
  597. begin
  598.   LocalKey := TranslateWinHotKeyToLocal(Message.LParam);
  599. if LocalKey = scCtrl + scAlt + VK_F10 then
  600. begin
  601. // 系統開關
  602.     TimerFinder.Enabled := not TimerFinder.Enabled;
  603.     Windows.Beep(3000100);
  604. endelseif LocalKey = scCtrl + scAlt + VK_F11 then
  605. begin
  606. // 設定原點
  607.     FetchWindowImage(FSCBitMap);
  608.     CalcCurrentPos;
  609.     CenterPosX := FCurGamePos.X;
  610.     CenterPosY := FCurGamePos.Y;
  611.     Windows.Beep(2000100);
  612.     Windows.Beep(2500100);
  613. endelseif LocalKey = scCtrl + scAlt + VK_F12 then
  614. begin
  615. // 調出設定框
  616.     SysSetMenuItemClick(nil);
  617. endelseif LocalKey = scCtrl + scAlt + VK_F1 then
  618. begin
  619. // 關閉執行緒
  620. try
  621. if Assigned(BeepThread) then
  622. begin
  623.         BeepThread.Terminate;
  624. end;
  625. except
  626. end;
  627. endelseif LocalKey = scCtrl + scAlt + VK_F2 then
  628. begin
  629.     SendFetionMsg('天龍八部助手測試!');
  630. end;
  631. end;
  632. { TBeepThread }
  633. constructor TBeepThread.Create(BeepSecs: Integer);
  634. begin
  635. inherited Create(True);
  636.   FreeOnTerminate := True;
  637.   FBeepSecs := BeepSecs;
  638. // 記錄自己
  639.   BeepThread := Self;
  640. end;
  641. procedure TBeepThread.Execute;
  642. var
  643.   StartUnixTick: Cardinal;
  644. begin
  645.   StartUnixTick := DateTimeToUnix(Now);
  646.   SyncSendFetionMsg;
  647. whilenot Terminated do
  648. begin
  649. if DateTimeToUnix(now) - StartUnixTick > FBeepSecs then
  650.       Break;
  651.     Windows.Beep(4000300);
  652.     Sleep(700);
  653. end;
  654.   BeepThread := nil;
  655. end;
  656. procedure TBeepThread.SyncSendFetionMsg;
  657. begin
  658.   SendFetionMsg('TLBBHelper: 需要輸入驗證碼!');
  659. end;
  660. end.
  1. unit GlobalDefs;
  2. interface
  3. uses
  4.   Windows;
  5. { 相關配置引數 }
  6. const
  7.   LIFE_MAX        = 124;
  8.   MAGIC_MAX       = 124;
  9.   BB_LIFE_MAX     = 96;
  10.   QT_MIN_COLOR = $FAFAFA;
  11.   QT_WIDTH = 237;
  12.   QT_HEIGHT = 298;
  13. var
  14.   FinderTimerMSec: Integer = 200;     // 系統Timer執行時間
  15.   LifeX: Integer = 64;                // 人物生命值X座標
  16.   LifeY: Integer = 32;                // 人物生命值Y座標
  17.   LifeColor: Integer = 0;             // 人物生命值取樣顏色(載入時初始化)
  18.   LifeMin: Integer = 50;              // 人物生命最小百分比
  19.   MagicX: Integer = 64;               // 人物魔法值X座標
  20.   MagicY: Integer = 38;               // 人物魔法值Y座標
  21.   MagicColor: Integer = 0;            // 人物魔法值取樣顏色(載入時初始化)
  22.   MagicMin: Integer = 50;             // 人物魔法最小百分比
  23.   BBLifeX: Integer = 91;              // 寶寶生命值X座標
  24.   BBLifeY: Integer = 71;              // 寶寶生命值Y座標
  25.   BBLifeColor: Integer = 0;           // 寶寶生命值取樣顏色(載入時初始化)
  26.   BBLifeMin: Integer = 30;            // 寶寶生命