Perform some experiments with a separate new project. Create a new “Console App (.NET Framework)” project, then replace the initial text of Program.cs with this code:
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
namespace ConsoleApp21
{
class Program
{
[DllImport( "user32" )]
private static extern IntPtr GetForegroundWindow( );
[DllImport( "user32", EntryPoint = "SendMessageW", CharSet = CharSet.Unicode )]
public static extern bool SendMessage( IntPtr hWnd, uint Msg, int wParam, StringBuilder lParam );
const int WM_GETTEXT = 0x000D;
static void Main( string[] args )
{
string previous_title = null;
for(; ; )
{
IntPtr hwnd = GetForegroundWindow( );
if( hwnd == IntPtr.Zero ) continue;
StringBuilder sb = new StringBuilder( 700 );
SendMessage( hwnd, WM_GETTEXT, sb.Capacity, sb );
string title = sb.ToString( );
if( previous_title != title )
{
previous_title = title;
Console.WriteLine( $"Window title: {title}" );
}
Thread.Sle\u0065p( 100 );
}
}
}
}
It will display the title of current application. You can move this test window to second monitor or minimise it and restore later. Activate other windows and check that the titles are displayed by this test.