1::::::<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=335821<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=1637034<br>2:::::::::<br>function GetSysFocus: Integer;<br>var<br>hFgWin, FgThreadID, hFocusWin: Integer;<br>begin<br>hFgWin := GetForegroundWindow;<br>FgThreadID := GetWindowThreadProcessID(hFgWin, nil);<br>if AttachThreadInput(GetCurrentThreadID, FgThreadID, True) then<br>begin<br>hFocusWin := GetFocus;<br>Result := GetFocus;<br>AttachThreadInput(GetCurrentThreadID, FgThreadID, False);<br>end<br>else<br>Result := GetFocus;<br>end; <br>///<br>procedure TForm1.Timer1Timer(Sender: TObject);<br>begin<br>listbox1.items.add(intToStr(GetSysFocus()));<br>end;