procedure TForm1.Timer1Timer(Sender: TObject);
var
ThreadID: Cardinal;
FocusWindow,FocusControl: HWND;
begin
FocusWindow:= GetForegroundWindow;
ThreadID:= GetWindowThreadProcessId(FocusWindow,nil);
AttachThreadInput(ThreadID,GetCurrentThreadId,True);
FocusControl:= GetFocus;
AttachThreadInput(ThreadID,GetCurrentThreadId,False);
Edit1.Text:= Format('$%8X',[FocusControl]);
end