Check if an app is running in fullscreen nodeJS

I’m making this widget in electron that shows up on the screen when you press ctrl+space.
I only want the widget be able to show up when there’s no app running in fullscreen mode.

I’ve tried using powershell but that doesn’t seem to work

const { exec } = require('child_process')
function isFullscreenAppRunning() {
    return new Promise((resolve, reject) => {
        const script = `
        function Is-AppFullScreen {
                param(
                [Parameter(Mandatory = $true)]
                [string] $ProcessName
                )
            
                # Get main screen resolution
                $screenWidth = (Get-Screen).WorkingArea.Width
                $screenHeight = (Get-Screen).WorkingArea.Height
            
                # Get window of the process
                $window = Get-Process -Name $ProcessName | Where-Object {$_.MainWindowTitle -ne $null} | Select-Object -ExpandProperty MainWindowHandle
            
                if ($window) {
                # Get window dimensions (accounting for borders)
                $windowRect = [System.Drawing.Rectangle]::FromLTRB((Get-Window -Handle $window).Left, (Get-Window -Handle $window).Top, (Get-Window -Handle $window).Right, (Get-Window -Handle $window).Bottom)
                $windowWidth = $windowRect.Width - (Get-Window -Handle $window).BorderWidth
                $windowHeight = $windowRect.Height - (Get-Window -Handle $window).BorderHeight
            
                # Check if window dimensions match screen resolution (considering potential rounding errors)
                return ($windowWidth -eq $screenWidth -and $windowHeight -eq $screenHeight)
                } else {
                # Process not found or no main window
                return $false
                }
            }
            
            # Check all processes with a main window title
            $isAnyAppFullScreen = $false
            Get-Process | Where-Object {$_.MainWindowTitle -ne $null} | ForEach-Object {
                $processName = $_.Name
                if (Is-AppFullScreen -ProcessName $processName) {
                $isAnyAppFullScreen = $true
                # Exit loop once a fullscreen app is found (optional for performance)
                break
                }
            }
            
            # Return true if any app is fullscreen, false otherwise
            return $isAnyAppFullScreen
            `
        
        exec(`powershell -command "${script}"`, (err, stdout, stderr) => {
            if (err) {
            reject(err)
            return
            }
            resolve(stdout.trim() === 'True')
        })
    })
}