Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Is there a way within vb to find which window has focus on a computer? For instance if IE, Open Office Writer and Photoshop are open, how can I programmatically tell which one has focus?
Posted

1 solution

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 />}


 
Share this answer
 


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900