#include <iostream>
#include <algorithm>
#include <thread>
#include <random>
#include <windows.h>
using namespace std::chrono_literals;
[ [ nodiscard ] ] auto __fastcall random_string( std::uint32_t length ) -> std::wstring {
static auto& alphanums = "0123456789"
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
thread_local static std::mt19937 rg{ std::random_device{ }( ) };
thread_local static std::uniform_int_distribution< std::string::size_type > alpha( 0, sizeof( alphanums ) - 2 );
std::wstring outstr{ };
outstr.reserve( length );
while ( length-- )
outstr += alphanums[ alpha( rg ) ];
return outstr;
}
[ [ nodiscard ] ] auto __fastcall random_title( const std::uint32_t length, const std::chrono::milliseconds sleep_duration ) -> void {
while ( true ) {
( SetConsoleTitleW )( random_string( length ).c_str( ) );
( std::this_thread::sleep_for )( sleep_duration );
}
}
auto __stdcall main( ) -> void {
std::thread pthread( random_title, /*title length*/32, /*sleep duration*/1000ms );
pthread.join( );
std::getchar( ); // for pause command prompt ^^
}