T tripleh Unregistered / Unconfirmed GUEST, unregistred user! 2007-02-24 #1 这个窗口的Caption是动态变化的。但是确定有‘ABCD’这个四个字符。他变化时只是在后面加随机的空格。看大家怎么取得该窗口的句柄!
暗 暗夜中独舞 Unregistered / Unconfirmed GUEST, unregistred user! 2007-02-25 #2 //获得窗口文本<br>function GetWndText(hWnd: HWND): String;<br>Var<br> Ret:LongInt;<br> mTextChar;<br> Buf:Integer;<br>begin<br> Ret:=SendMessage(hWnd,WM_GETTEXTLENGTH,0,0)+1;<br> GetMem(mText,Ret);<br> try<br> Buf:=LongInt(mText);<br> SendMessage(hWnd,WM_GETTEXT,Ret,Buf);<br> Result:=StrPas(mText);<br> finally<br> FreeMem(mText,Ret);<br> end;<br>end;<br><br><br>Function GetWND:HWND;<br>begin<br>h:=GetForegroundWindow;<br>//循环查找<br> While (h<> 0) do <br>begin<br> if (Pos('ABCD',GetWndText(hQQ))>0) then<br> begin<br> result:=h;<br> exit;<br> end;<br> end;<br> h := FindWindowEx(0,h,'', nil <br>end;
//获得窗口文本<br>function GetWndText(hWnd: HWND): String;<br>Var<br> Ret:LongInt;<br> mTextChar;<br> Buf:Integer;<br>begin<br> Ret:=SendMessage(hWnd,WM_GETTEXTLENGTH,0,0)+1;<br> GetMem(mText,Ret);<br> try<br> Buf:=LongInt(mText);<br> SendMessage(hWnd,WM_GETTEXT,Ret,Buf);<br> Result:=StrPas(mText);<br> finally<br> FreeMem(mText,Ret);<br> end;<br>end;<br><br><br>Function GetWND:HWND;<br>begin<br>h:=GetForegroundWindow;<br>//循环查找<br> While (h<> 0) do <br>begin<br> if (Pos('ABCD',GetWndText(hQQ))>0) then<br> begin<br> result:=h;<br> exit;<br> end;<br> end;<br> h := FindWindowEx(0,h,'', nil <br>end;