我在打游戏的时候,希望通过键值来执行自己的程序,可是当我的程序窗口打开时,游戏自动被最小化了。请问如何解决!(20分)

  • 主题发起人 主题发起人 inbreak
  • 开始时间 开始时间
I

inbreak

Unregistered / Unconfirmed
GUEST, unregistred user!
我在打游戏的时候,希望通过键值来执行自己的程序,<br><br>可是当我的程序窗口打开时,游戏自动被最小化了。请问如何解决!<br><br>哦,对了。就象现在的 网络游戏 外挂那样。。可以,程序窗口浮在游戏窗口上面<br><br>而仍然可以观看游戏情况。<br><br>肯求解答。由于我是初学者,所以请各位大侠详细一点点说明怎么样做或给出完整的代码。<br><br>谢谢!!!!<br>
 
在线等待中~~~~~~~~~~~~~~~~~~~~~~~~~~
 
在线等待中~~~~~~~~~~~~~~~~~~~~~~~~~~
 
你的程序可以不必悬浮在前面<br>在后台接收消息并处理就可以了<br><br>
 
如果我做游戏游戏修改程序呢??<br><br>要象金山游戏那样,窗口切来切去吗??<br><br>不能象一些现在的网络游戏一样。。。随时执行呀进行修改。。
 
在线等待中~~~~~~~~~~~~~~~~~~~~~~~~~~
 
你在做外挂?
 
全局hook+dll中调用form
 
在线等待中~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
转贴:<br>标 题:金山游侠在DxDraw中显示大露秘密! (818字)<br>发信人:柯南[CCG]<br>显示一个对话框用api: <br>DialogBox或其他. <br>msdn中的描述: <br>int DialogBox( <br>&nbsp; HINSTANCE hInstance, &nbsp;// handle to application instance <br>&nbsp; LPCTSTR lpTemplate, &nbsp;// identifies dialog box template <br>&nbsp; HWND hWndParent, &nbsp; &nbsp; &nbsp;// handle to owner window <br>&nbsp; DLGPROC lpDialogFunc &nbsp;// pointer to dialog box procedure <br>); <br>,看了看,如果搞顶其中的hInstance(就是你的dll,不用找了)和WndParent(程序的主窗口).<br>不就行了吗. 好了,你只要可以hook到CreateWindow或....Ex函数就可以搞到hWnd了,<br>如何hook这个API?不能用一般的方法,因为CreateWindow之前还没建立窗口,所以我们<br>用特殊的方法,在目标程序运行前,先执行loadlibrary(ourdll)就行了.具体代码挺难<br>写,不过肯定行的. 对了,以前有个朋友说不行,我认为就是没有找到hwnd的原因. <br>找hwnd还有其他一些非hook的方法,不过不建议用,因为不能通用! <br>其实hwnd可以用GetForegroundWindow来找连hook都省了. <br>狗屁技术,计算机充满了炮末!<br>
 
[:(]5555。。。<br>贴了90%的贴子,被一个非法操作就给over了。<br>那就再写一遍吧。<br>问题基本搞定,不一定要用dialgobox,关键是要现实的窗体的parnet必须要设成<br>游戏的窗体。这样就可以弹出自己的窗体,而游戏的窗体也不会最小化了。<br>我写了一个,w2k+delphi6+q3a测试通过。<br>代码比较乱,注意看注释。<br>热键是左边的win建加小键盘上得*建<br>ps,别忘了给分。[:D]<br>//--------------App part start----------------<br>//form上放两个button.<br>//Copyright by tt.t(ttui) @2k+3.1.19@bit<br><br>unit test;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, <br><br>Dialogs,<br>&nbsp; StdCtrls;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; Button2: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; &nbsp; procedure Button2Click(Sender: TObject);<br>&nbsp; &nbsp; procedure FormDestroy(Sender: TObject);<br>&nbsp; &nbsp; procedure FormCreate(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br>function sethook:bool;external 'ptdll.dll';<br>function endhook:bool;external 'ptdll.dll';<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>//if<br>&nbsp;sethook;<br>&nbsp;// then showmessage('Hook Successful');<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>//if<br>endhook;<br>// then showmessage('Unhook Successful!!');<br>end;<br><br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br>//endhook;<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>//sethook;<br>end;<br><br>end.<br>//--------------App part end------------------<br><br>//--------------DLL part start------------------<br>//--------------library project------------------<br>library ptdll;<br><br>uses<br>&nbsp; SysUtils,<br>&nbsp; Classes,<br>&nbsp; Windows,<br>&nbsp; Messages,<br>&nbsp; dll_vol in 'dll_vol.pas',<br>&nbsp; dia in 'dia.pas' {Form1};<br><br>{$R *.RES}<br><br>exports sethook,endhook;<br>begin<br>hNextHookProc := 0;<br>procSaveExit := ExitProc;<br>ExitProc := @HotKeyHookExit;<br>end.<br>//-------------------dll_vol unit-----------------------<br>unit dll_vol;<br><br>interface<br><br>uses Windows,Messages,Dialogs,Sysutils,dia;<br><br>var<br>&nbsp; hNextHookProc: HHook;<br>&nbsp; procSaveExit: Pointer;<br><br>&nbsp; function sethook:bool;export;<br>&nbsp; function hookproc(iCode:Integer;wParam: WPARAM;lParam: LPARAM): <br><br>LRESULT; stdcall;<br>&nbsp; function endhook:bool;export;<br>&nbsp; procedure HotKeyHookExit;far;<br><br>implementation<br><br>function HookProc(iCode: integer; wParam: wParam; lParam: lParam): <br><br>LResult; stdcall;<br>var<br>&nbsp; hwnd:dword;<br>&nbsp; AppRect:TRect;<br>&nbsp; title:pchar;<br>// &nbsp;dc:hdc;<br>begin<br>&nbsp; result:=0;<br>&nbsp; &nbsp; if iCode&lt;0 then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; CallNextHookEx(hnexthookproc,iCode,wParam,lParam);<br>&nbsp; &nbsp; &nbsp; result:=0;<br>&nbsp; &nbsp; &nbsp; Exit;<br>&nbsp; &nbsp; end;<br>{<br>&nbsp; &nbsp; dc:=getdc(0);<br>&nbsp; &nbsp; textout(dc,20,20,pchar(inttohex(wparam,3)),3);<br>&nbsp; &nbsp; releasedc(0,dc);<br>}<br>&nbsp; if ((lParam and $80000000)=0) and<br>&nbsp; &nbsp; &nbsp;(GetKeyState(VK_LWIN)&lt;0) and (wParam=$6a) then<br>&nbsp; begin<br>&nbsp; &nbsp; Messagebeep(0);<br>&nbsp; &nbsp; hwnd:=getforegroundwindow;<br>&nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; GetMem(title,255);<br>&nbsp; &nbsp; &nbsp; getwindowtext(hwnd,title,255);<br>&nbsp; &nbsp; &nbsp; if title&lt;&gt;'_Msg_Dx_' then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; form1:=TForm1.CreateParented(hwnd);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetWindowRect(hwnd,AppRect);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; form1.Left:=(AppRect.Right-AppRect.Left) div 2;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; form1.Top:=(AppRect.Bottom-AppRect.Top) div 2;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; form1.Caption:='_Msg_Dx_';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; form1.ShowModal;<br>&nbsp; &nbsp; &nbsp; &nbsp; finally<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; form1.Free;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; finally<br>&nbsp; &nbsp; &nbsp; FreeMem(title);<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; result:=1;<br>&nbsp; end;<br>end;<br><br>function sethook:bool;export;<br>begin<br>&nbsp; result:=false;<br>&nbsp; if hnexthookproc&lt;&gt;0 then exit;<br>&nbsp; hNextHookProc := SetWindowsHookEx(WH_KEYBOARD,hookproc,HInstance,0);<br>&nbsp; Result := hNextHookProc &lt;&gt; 0;<br>end;<br><br>procedure hotkeyhookexit;<br>begin<br>&nbsp; if hNextHookProc &lt;&gt; 0 then endHook;<br>&nbsp; ExitProc := procSaveExit;<br>end;<br><br>function endhook:bool;export;<br>begin<br>&nbsp; if hNextHookProc &lt;&gt; 0 then<br>&nbsp; begin<br>&nbsp; &nbsp; UnhookWindowshookEx(hNextHookProc); // 解除 Keyboard Hook<br>&nbsp; &nbsp; hNextHookProc := 0;<br>&nbsp; end;<br>&nbsp; Result := hNextHookProc = 0;<br>end;<br><br>end.<br>//----------------dia unit-------------------<br>//注意!!form的borderstyle必须设成bsdialog!!<br>unit dia;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs, StdCtrls;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>end.<br><br>//--------------DLL part end------------------<br>
 
接受答案了.
 
to tt.t<br>&nbsp; 你好,我用你的代码,在游戏中可以呼出窗体,但是游戏就静止不动了<br>我把form1.showmodal改成form1.show,结果窗体一呼出来马上就不见<br>了,请问如何解决窗体呼出后游戏还继续运行?
 
你要把窗口的扩展风格设置在最前面!
 
不要用模式窗口,否则要等待窗口返回,用无模式的,并且设置风格在最前面!
 
你好,我用你的代码,在游戏中可以呼出窗体,但是游戏就静止不动了<br>我把form1.showmodal改成form1.show,结果窗体一呼出来马上就不见<br>了,请问如何解决窗体呼出后游戏还继续运行? <br><br>来自:lsaturn, 时间:2003-11-25 9:46:00, ID:2315071<br>你要把窗口的扩展风格设置在最前面! &nbsp;<br>来自:lsaturn, 时间:2003-11-25 10:01:00, ID:2315112<br>不要用模式窗口,否则要等待窗口返回,用无模式的,并且设置风格在最前面<br>---------------------------<br>我也出现上面的问题,这个无模式窗口要怎么设??<br>我把formstyle 设成 StayOnTop了,但还是不行.
 
form1.create(slef);<br>form1.show;
 
后退
顶部