下面提供几种我找到的资料。没有检测,供参考
var
hCurrentWindow: HWnd;
szText: array[0..254] of char;
begin
hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);
While hCurrentWindow <> 0 Do
Begin
If GetWindowText(hCurrentWindow, @szText, 255) > 0 Then
ListBox1.Items.add(Strpas(@szText));
hCurrentWindow := GetNextWindow(hCurrentWindow, GW_HWNDNEXT);
End;
procedure TForm1.Timer1Timer(Sender: TObject);
var
hWndPt:HWND;
pBuf:PChar;
pt:TPoint;
nMax:DWORD;
begin
GetCursorPos(pt);
nMax:=1024;
hWndPt:=WindowFromPoint(pt);
if hWndPt<>0 then
begin
GetMem(pBuf,1024);
SendMessage(hWndPt,WM_GETTEXT,nMax,DWORD(pBuf));
Memo1.Lines.Add(string(pbuf));
FreeMem(pBuf);
end;
memo1.SelStart :=length(memo1.Text);
end;