procedure ForceForegroundWindow(h: HWND); 
var Input: TInput; 
begin
 ZeroMemory(@Input, SizeOf(Input));
 SendInput(1, Input, SizeOf(Input));
 SetForegroundWindow(h);//changed
end;