'Application that can open program in full screen?

I need to make an application that starts new program (ex. notepad) in fullscreen mode. Can I do that in c#?

I'd appreciate a code sample.Thanks:)



Solution 1:[1]

You can use Process.Start with a ProcessStartInfo object which has a WindowStyle property. You can set that property so that the window starts maximized.

Adapted from the example at Process.Start:

ProcessStartInfo startInfo = new ProcessStartInfo("notepad.exe");
startInfo.WindowStyle = ProcessWindowStyle.Maximized;
Process.Start(startInfo);

If the process is already running, see here

Solution 2:[2]

F11 key is most often used to enter and exit fullscreen mode, so after program starts, you can call User32.SendInput WinApi (use PInvoke.User32 from Nuget).

   static async Task Main(string[] args)
    {
        StartProcess(_Config.FileName, _Config.Args);
        await Task.Delay(_Config.Delay);
        SendKey_F11();
    }

    static void StartProcess(string fileName, string args)
    {
        new Process()
        {
            StartInfo = new ProcessStartInfo()
            {
                FileName = fileName,
                Arguments = args
            }
        }
        .Start();
    }

    static void SendKey_F11()
    {
        PInvoke.User32.INPUT inp = new PInvoke.User32.INPUT();
        inp.type = PInvoke.User32.InputType.INPUT_KEYBOARD;
        inp.Inputs.ki.wVk = PInvoke.User32.VirtualKey.VK_F11;
        inp.Inputs.ki.wScan = PInvoke.User32.ScanCode.F11;

        PInvoke.User32.SendInput(1, new[] { inp }, 40);
    }

In the same way you can call any other hotkey command to enter fullscreen mode.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 csh