Script to momentarily change the refresh rate on second monitor

I have 2 monitors, however my second monitor seems to loose connection with the computer. I discovered that if I go into System Settings, displays, click on the second monitor, and momentarily change the refresh rate to 50hz, the monitor magically connects again. I then return the refresh rate to 60hz.

I know nothing about coding. Can someone please write me a script that will do this? I’d like to add it into my BetterTouchTool button.

The name of my second monitor is “Samsung (2)”
I’m using MacOS 26

Note that I found a good YouTube video and tried to do this on my own, but was unsuccessful.