C#:检测哪个应用程序具有焦点 [英] C#: Detecting which application has focus

查看:167
本文介绍了C#:检测哪个应用程序具有焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望创建一个C#应用程序,该应用程序根据当前具有焦点的应用程序来更改内容。因此,如果用户使用Firefox,我的应用程序就会知道这一点。同样适用于Chrome,Visual Studio,TweetDeck等。

I'm looking to create a C# application that changes content according to which application currently has focus. So if the user is using Firefox, my app would know that. Same for Chrome, Visual Studio, TweetDeck etc.

有可能吗?如果可以,我将如何实现呢?

Is this possible, and if so - how would I go about achieving it?

我有很多要求,但是值得尝试。

I have a feeling I'm asking for to much - but it's worth a try.

非常感谢。

推荐答案

看看 Application.AddMessageFilter ,然后查找WM_ACTIVATEAPP消息,该消息将告诉您何时激活了应用程序,即获得关注。

Take a look at Application.AddMessageFilter, and look for WM_ACTIVATEAPP messages, which will tell you when an app is activated, i.e. receives focus.

这篇关于C#:检测哪个应用程序具有焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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