在计算机上找到活动窗口. [英] Find the active window on a computer.

查看:87
本文介绍了在计算机上找到活动窗口.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在vb中有没有一种方法可以找到哪个窗口集中在计算机上?例如,如果IE,Open Office Writer和Photoshop是打开的,那么我该如何以编程方式确定哪一个具有焦点?

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?

推荐答案

这将需要一些代码类来实现本机窗口功能,这是C#代码,您可以将其移植到VB
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 />}






这篇关于在计算机上找到活动窗口.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆