Automate Webcam Swap

Is there any way to automate changing the webcam depending on what screen my cursor is on? I have a laptop monitor with its own webcam and an external monitor with a second webcam. I would like to achieve the effect that when my cursor is on the laptop screen I use the laptop webcam during video conferencing on Google Meet, and when my cursor is on the external monitor I will automatically use my second webcam.