How to lock cursor position while rotating camera?

I did it like this. So i can “rotate infinite” even when the cursor hits the windows edge. [Checked]
Now i need a solution that the mouse “Stops moving” when i press the right mouse button, but still allows rotating the camera.
I’m testing few things but can’t do it somehow.