不好意思,我的帐号还不能提问,在这里问个差不多的问题<br>我要做一个(热血江湖)会加自动加血加蓝的外挂,<br>具体代码如下:<br>unit Mainf;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, ComCtrls,StdCtrls, ExtCtrls;<br><br>type<br> TMainForm = class(TForm)<br> TimerSM: TTimer;<br> TimerNG: TTimer;<br> TimerJN: TTimer;<br> CheckBoxSM: TCheckBox;<br> CheckBoxNG: TCheckBox;<br> EditSM: TEdit;<br> EditNG: TEdit;<br> CheckBoxJN: TCheckBox;<br> Button1: TButton;<br> Button2: TButton;<br> Label1:TLabel;<br> procedure CheckBoxSMClick(Sender: TObject);<br> procedure TimerSMTimer(Sender: TObject);<br> procedure Button2Click(Sender: TObject);<br> procedure Button1Click(Sender: TObject);<br> procedure CheckBoxNGClick(Sender: TObject);<br> procedure TimerNGTimer(Sender: TObject);<br> procedure CheckBoxJNClick(Sender: TObject);<br> procedure TimerJNTimer(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br>const<br> SHENGMING: dword = $01453318; //红<br> NEIGONG: dword = $0145331C; // 蓝<br><br>var<br> MainForm: TMainForm;<br><br> hw: HWND;<br> pid: dword;//游戏句柄ID<br> h: THandle;//游戏句柄<br> tt: Cardinal;<br> procedure KeyF2;//按键<br> procedure KeyF3;<br> procedure KeyF4;<br><br>implementation<br><br>{$R *.dfm}<br>procedure TMainForm.Button1Click(Sender: TObject);<br>begin<br> if h = 0 then //如果句柄没打开<br> begin<br> hw:=FindWindow(nil,'YB_OnlineClient'); ///<br> if hw = 0 then /// 获得句柄ID<br> Exit; ///<br> GetWindowThreadProcessId(hw, @pid); ///<br> h := OpenProcess(PROCESS_ALL_ACCESS, false, pid); ///<br> if h = 0 then ///打开句柄<br> Exit;<br> ///<br> end;<br> TimerNG.Interval := 1000 div trunc(5);<br> TimerSM.Interval := 1000 div trunc(5);<br> TimerJN.Interval := 1000 div trunc(2);///每秒钟运行次数<br>end;<br>procedure TMainForm.CheckBoxSMClick(Sender: TObject);<br>begin<br> if CheckBoxSM.Checked then //控制Timer是否运行<br> begin<br> EditSM.Enabled := false;<br> TimerSM.Enabled := true;<br> end<br> else<br> begin<br> EditSM.Enabled := true;<br> TimerSM.Enabled := false;<br> end;<br>end;<br><br>procedure TMainForm.TimerSMTimer(Sender: TObject);<br>var<br> Sm: integer;<br> // tt: DWORD;<br>begin<br> ReadProcessMemory(h,pointer( SHENGMING), @Sm,sizeof(Sm), tt);<br>//扫描内存数据<br> <br> if ((Sm <= StrToInt(EditSM.Text))and(Sm<>0)) and (h<>0) then<br>//如果血量值少于设定值并且不等于0<br> begin<br> KeyF3;<br> //按F3键<br> Label1.Caption :='F3运行中';<br> end;<br><br>end;<br><br>procedure KeyF2;<br>begin<br> keybd_event(VK_F2,mapvirtualkey(VK_F2,0),0,0);<br> keybd_event(VK_F2,mapvirtualkey(VK_F2,0),keyeventf_keyup,0);//按F2键<br>end;<br>procedure KeyF3;<br>begin<br> keybd_event(VK_F3,mapvirtualkey(VK_F3,0),0,0);<br> keybd_event(VK_F3,mapvirtualkey(VK_F3,0),keyeventf_keyup,0);//按F3键<br>end;<br>procedure KeyF4;<br>begin<br> keybd_event(VK_F4,mapvirtualkey(VK_F4,0),0,0);<br> keybd_event(VK_F4,mapvirtualkey(VK_F4,0),keyeventf_keyup,0);//按F4键<br>end;<br>procedure TMainForm.Button2Click(Sender: TObject);<br>begin<br> if h <> 0 then<br> begin<br> MessageBeep(0);<br> CloseHandle(h);<br> end;<br> close;<br>end;<br>end.<br><br>没有进游戏时,Label没有反应,<br>进入游戏了,按下按钮,当血量少于设定值时Label改变,说明Timer在运行,<br>可是游戏里不会自动加血,于是我改变了一下按键,把F3改成了F4,<br>游戏里还是没有反应,但我切到外挂窗口,按一下Alt键,外挂窗口关闭,<br>由此证明模拟键盘F4键一直进行中<br>后来我又换了一个模拟键盘的方法,<br>改变如下:<br>procedure KeyF3;<br>begin<br> PostMessage(Application.Handle, WM_KEYDOWN, VK_F4, 0);<br> PostMessage(Application.Handle, WM_KEYUP, VK_F4, 0);<br>end;<br>和<br>procedure KeyF3;<br>begin<br> PostMessage(h, WM_KEYDOWN, VK_F4, 0);<br> PostMessage(h, WM_KEYUP, VK_F4, 0);<br>end;<br>在游戏里还是没有反应,并且外挂窗口也没有反应了,但是Label标签改变<br>由是我再改成<br>procedure KeyF3;<br>begin<br> PostMessage(h, WM_KEYDOWN, VK_F4, 0);<br> PostMessage(h, WM_KEYUP, VK_F4, 0);<br> setcursorpos(500,400);<br> mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);<br> mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);<br>end;<br>这时鼠标在游戏里点击正常,键盘没有反应<br><br>在此麻烦大侠帮下忙,找下问题所在,<br>或再给几个模拟键盘的方法<br>非常感谢!!!!!