skip to Main Content

I am trying to fullscreen my C# Visual studio console app, but to no success.

I tried a couple of methods but I am still new to creating console applications in Visual Studio, and nothing really worked. All I need is some C# code to get my terminal app into fullscreen on startup. I am on MacOSX, any help would be appreciated.

2

Answers


  1. I had the same problem a while ago, I solved it using the "System.Runtime.InteropServices" APIs, do something like:

    using System;
    using System.Runtime.InteropServices;
    
    class Program
    {
         [DllImport("libc.dylib", EntryPoint = "system")]
         private static extern int System(string exec);
    
         static void Main()
         {
             const string command = "osascript -e 'tell application "Terminal" to set bounds of front window to {0, 0, 1920, 1080}'";
             System(string.Format(command, Console.WindowWidth, Console.WindowHeight));
    
             Console.WriteLine("Full screen console application!");
             Console.ReadLine();
         }
    }
    

    Following something along those lines should solve your problem.

    Login or Signup to reply.
  2. You can just use old fashioned escape commands I suppose. Here is a basic example:

    using System.Diagnostics;
    using System.Runtime.InteropServices;
    
    Console.WriteLine("Hello, World!");
    
    [DllImport("libc")]
    static extern int system(string exec);
    
    
    system(@"printf 'e[8;50;100t'"); //adjust the 50 and 100t for whatever size you are wanting.
    system(@"printf 'e[3;0;0t'"); // moves terminal to top left
    
    while (true)
    {
        var someText = Console.ReadLine();
        Console.WriteLine(someText);
    }
    

    Here is a video showing the size movements

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search