Command line arguments you need to handle are:
/s = Run screen saver in full screen (normal start of screen saver)
/c = user clicked the configure button and if your screen saver has any configuration, you should show the configuration screen with the different settings the user can edit.
/p = Run screensaver in preview mode, this is the tiny version you can see when you select the screen saver.
For the /s you will get a second parameter that is the handler for the frame that you will run the preview in. In C# you will do something like this:
First you need to import some standard window methods:
[DllImport(“user32.dll”)]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport(“user32.dll”)]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
[DllImport(“user32.dll”, SetLastError = true)]
static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport(“user32.dll”)]
static extern bool GetClientRect(IntPtr hWnd, out Rectangle lpRect);
Next, get the window handler id from argument 2 after the /p.
string handler = args[1];
IntPtr previewWndHandle = new IntPtr(long.Parse(handler));
Finally adjust your form to be a child of the Windows Screen Saver settings window so it will be terminated along with this. These code lines are how to do it with WinForms. I am not sure how to do this in Godot, but try to Google it.
// Make your window a child of the Windows Screen Saver dialog
SetParent(this.Handle, PreviewWndHandle);
// Make this a child window close when the parent dialog closes
// GWL_STYLE = -16, WS_CHILD = 0x40000000
SetWindowLong(this.Handle, -16, new IntPtr(GetWindowLong(this.Handle, -16) | 0x40000000));
// Place our window inside the parent with the correct position and size
Rectangle ParentRect;
GetClientRect(PreviewWndHandle, out ParentRect);
Size = ParentRect.Size;
Location = new Point(0, 0);
Then your screen saver should run as a small preview inside the Windows Screen Saver selector (if a WinForms application). Happy coding.