Executing script in hidden Rhino Window

Hey everyone,
I’m trying to find a way to execute a short series of commands in Rhino 8 WIP without displaying the Rhino window…

I found this option from shell which works fine

e.g.: “C:\Program Files\Rhino 8 WIP\System\Rhino.exe” /nosplash /runscript=“_SetCurrentRenderPlugIn Rhinoceros _Render _-SaveRenderWindowAs .\test.jpg _-CloseRenderWindow _-Exit” test.3dm

but opens a Rhino window with which the user can interact… I would like to avoid that. Are there other options available?

My goal is to create a plugin in Rhino7 which executes commands from Rhino8WIP and then closes it…
Thnak you
Andre

If you want to open a separate software program and keep its GUI hidden, one way to do this is by using the Windows API function ShowWindow().

This function allows you to change the visibility of the main window of a process. You can use the function to hide the window by specifying the window handle and the SW_HIDE flag.

Here’s an example of how you can use the ShowWindow() function to hide the main window of a separate process in C#:

using System.Runtime.InteropServices;

class Program
{
    [DllImport("user32.dll")]
    private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

    private const int SW_HIDE = 0;

    static void Main()
    {
        // Start the separate process
        var process = new Process()
        {
            StartInfo = new ProcessStartInfo("path\\to\\program.exe")
            {
                UseShellExecute = false
            }
        };
        process.Start();

        // Wait for the process to start
        Thread.Sleep(1000);

        // Get the main window handle
        var hWnd = process.MainWindowHandle;

        // Hide the main window
        ShowWindow(hWnd, SW_HIDE);
    }
}

You can achieve your goal, however It is not easy at all, because now you got a hidden Rhino window.

One solution would be to add a shortkey to the command you want to automate, and use SendKey from .NET to send the command on the hidden window, then SENDKEY and use a shortcut you have for save, finally kill the process.

I do not know an easy way to reach your goal, but you can trick your way into it, It doesnt seem worth the effort though.

1 Like

Yeah, might not be worth it… but still gonna try.
Thank you for your response, I tried it and I got the first part working well already