This would need some code class to native window function, here is C# code you can port it to VB
using System;<br />using System.Windows.Forms;<br />using System.Runtime.InteropServices;<br /><br /><br />public class MyClass<br /><br />{<br /> [DllImport("user32.dll")]<br /> private static extern IntPtr GetForegroundWindow();<br /> [DllImport("user32.dll")]<br /><br /> public static void Main() {<br /> IntPtr handle = GetForegroundWindow();<br /> }<br />}