Get current active window title in C

I want to write an X-Chat plugin in which users can execute a CTCP request for my client, as a result of which the plugin / X-Chat will respond with my current active window title.

It would be great for other IRC users to understand that I want them to be able to determine what I am doing if I am full screen (playing a game, watching a video, etc.).

X-Chat plugins are written in C, so I need a way to determine the current active window title using the Windows API calls with C. Can anyone tell me how to do this?

Thank.

+5
source share
2 answers

, GetForegroundWindow(), , , GetWindowText(), :

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

All Articles