Extending display via AirPlay mirroring with AppleScript

Hello guys!

I wanted to see if anyone can help me. I have a MacBook M1 and have one monitor connected via HDMI, but the second one, via a MagicLink cable that uses actually AirPlay. So, I use it as if doing screen mirroring and then selecting the monitor name. I would like to automate it via Apple Script, since my previous attempts with Automator fail because it uses mouse movements.

I can connect to the monitor via the settings app, then displays and then clicking the plus sign to the right and then selecting the monitor. I have tried many apps to do this via terminal, but they use the HDMI monitor, not this one.

Is there a way to automate it?

Thanks!

For anyone interested in the solution, I found this and worked: macos ventura - Start Screen Mirroring in Control Center with AppleScript - Stack Overflow