检查窗口是否处于活动状态 [英] Checking if a window is active

查看:81
本文介绍了检查窗口是否处于活动状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 GetAsyncKeyState(); 的控制台应用程序,但是如果用户正在查看另一个窗口并按下按钮,则 GetAsyncKeyState (); 捡起它(我已经知道了)。

I have a console application that uses GetAsyncKeyState();, but if the user is on looking at another window and pressed a button, GetAsyncKeyState(); picked it up (I already knew that).

无需做 GetActiveWindow(); ,我还能如何检查我的窗口是否在顶部?

Without having to do GetActiveWindow();, how else could I check if my window is the one on top?

编辑: GetConsoleWindow()== GetForegroundWindow ()起作用。

推荐答案

要获取活动窗口,可以调用 GetActiveWindow GetFocus 将返回具有输入焦点的窗口的句柄。该窗口也可以是控件。因此,您可以对照窗口句柄查看它是否具有焦点。

To get the active Window you can call GetActiveWindow. GetFocus will return the handle of the window that has the input focus. This window can be a control as well. So you can check against your window handle and see if it has the focus.

这篇关于检查窗口是否处于活动状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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