获取用C当前活动窗口标题 [英] Get current active Window title in C

查看:122
本文介绍了获取用C当前活动窗口标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个X-聊天插件,用户将能够执行CTCP请求我的客户,即插件/ X-聊天会与我当前活动窗口的标题作出回应。

I want to write an X-Chat plugin where users will be able to perform a CTCP request to my client, whereby the plugin/X-Chat will respond with my current active window title.

这是真的很酷同胞IRC用户看到什么,我最多让他们确定我在做什么,如果我全屏幕(玩游戏,观看视频等)。

This would be really cool for fellow IRC users to see what I'm up to to allow them to determine what I'm doing if I'm full screen (playing a game, watching a video etc).

插件用于X聊天都用C写的,所以我需要使用从C Windows API调用任何人都可以就如何实现这一可能做劝确定当前活动窗口标题的方法吗?

Plugins for X-Chat are written in C, so I need a way of determining the current active Window title using Windows API calls from C. Can anyone advise on how this might be done?

感谢。

推荐答案

我的认为的你可以使用<一个href=\"http://msdn.microsoft.com/en-us/library/windows/desktop/ms633505%28v=vs.85%29.aspx\"><$c$c>GetForegroundWindow()以得到一个处理窗口的用户正在使用,然后使用<一个href=\"http://msdn.microsoft.com/en-us/library/windows/desktop/ms633520%28v=vs.85%29.aspx\"><$c$c>GetWindowText()拿到冠军:

I think you can use GetForegroundWindow() to get a handle to the window the user is using and then use GetWindowText() to get the title:

HWND foreground = GetForegroundWindow();
if (foreground)
{
    char window_title[256];
    GetWindowText(foreground, window_title, 256);
}

这篇关于获取用C当前活动窗口标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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