P
p2p
Unregistered / Unconfirmed
GUEST, unregistred user!
我看可以一个QQ轰炸机的代码,于是自己写了一段代码模仿在另外一个windows程序里的一个button的鼠标单击!代码是这样写的!<br>function GetButtonHandle(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br>var<br> buffer: array[0..255] of Char;<br> buffer1: array[0..255] of Char;<br>begin<br> Result := True;<br> //得到目标窗口的控件<br> GetClassName(hwnd,buffer,256);<br> //找到目标窗口的目标控件<br> if StrPas(Buffer)='Button' then<br> begin<br> GetWindowText(hwnd,buffer1,100);<br> if buffer1 = '确定' then<br> begin<br> PInteger(lparam)^ := hwnd; //得到目标控件的Hwnd(句柄)<br> Result:=False; //终止循环<br> end;<br> end;<br>end;<br>procedure tform1.button1onclick(sender:tobject);<br>var<br> myHandle,temphandle,Fbuttonhandle:Hwnd;<br>begin<br> myHandle:=FindWindow(nil,'test'); //就是窗口的Caption<br> if myHandle<>nil then<br> begin<br> tmpHandle := myHandle;<br> //在这里循环取到想要的句柄为止<br> //取按钮的FButtonHandle<br> EnumChildWindows(tmpHandle,@GetButtonHandle,Integer(@tmpHandle));<br> FButtonHandle := tmpHandle;<br>end;<br> SendMessage(FButtonHandle,MOUSEEVENTF_LEFTDOWN,0,0);<br> SendMessage(FButtonHandle,MOUSEEVENTF_LEFTUP,0,0);<br>end;<br>程序编译正常,但我怎么按button,在另外一个叫test的窗体里的名为'确定'的按钮也没有反应!<br>请教大虾们,我的程序到底出现了什么问题?拜托!<br>