How do I tell if the user is recording?

Godot version 4.1.1.stable

Hey! I’m new to Godot and have been learning things since late last year and I’ve been making a computer companion type of game (like kinitoPET or Outcore) and I’ve been wondering if I could detect if the user was recording and/or if I could start/stop it. Any help would be appreciated, thanks!

IDK about detecting if the screen is being recorded but you can detect if programs like OBS are open and assume it’s recording.

That’s what I did with Outcore and it worked well even if it did not detect 100% of the times the screen was recorded.

right, how would i detect other apps though? also, your game is epic

This is the C# code Outcore uses to find if a process is open:

public Process GetProcessByNames(params string [] targetProcessNames)
{
    Process[] runningProcesses = Process.GetProcesses();
    foreach (Process process in runningProcesses)
    {
        try
        {
            if(!process.HasExited)
            {
                foreach (var targetName in targetProcessNames)
                {
                    if (process.ProcessName == targetName && process.MainModule != null)
                    {
                        return process;
                    }
                }
            }  
        }
        catch { }

    }

    return null;
}

I then call it like this for OBS:

bool IsRecordingProgramOpen()
{
    return _windowController.GetProcessByNames("obs", "obs64") != null;
}

Note that Process.GetProcesses(); comes from the System.Diagnostics.Process namespace.

If you don’t use C# you’ll probably need to invoke native code that calls a similar function.

how can i make this code in godot format? if not, how could i connect this to a godot script?