VNCViewer.exe on specific monitor

I can't get this to work at all, I'm using a C# application and trying to force the viewer to monitor 1, I see a parameter for monitor but have no idea how to use it as there is no clear instruction on how to find \\.\Display1 or how to add it as a parameter (i.e. ="\\.\Display1" or =\\.\Display1 or =Display1 etc etc) 

Anyone have experience with this and can guide me on how to find the proper info that belongs beside monitor=?

0

Comments

11 comments
  • I think the Monitor parameter can accept a simple integer, but in C# you can use something like

    foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens) {
    Console.Log(screen.DeviceName);
    }

    I use something similar to enumerate displays in my project:

    https://github.com/jackyaz/DisplaySwitchVNC/blob/master/DisplaySwitch_VNC/VNC_Screen.cs

    0
    Comment actions Permalink
  • I need the vncviewer.exe to open on a specific monitor where the pc has multiple monitors, so process start vncviewer.exe (start on monitor 2). It always starts on primary monitor and I can move it after but that’s very annoying because if you are working on the primary monitor and I have the app refresh then it spams the primary monitor before moving the exe to the secondary monitor. I have tried integers and nothing I try gets the exe to first open on anything but the primary monitor!!!

    0
    Comment actions Permalink
  • Ah I see - the Monitor parameter will set which monitor the actual connection/session window will appear on, the main GUI appears bound to the primary monitor.

    Do you specifically need the main GUI to appear somewhere, or you could bypass that and launch the connection directly by passing the connection details directly to vncviewer.exe?

    0
    Comment actions Permalink
  • Sorry, it is the connection that pops up on the primary monitor, I’m passing arguments for ip address etc to the process.start. That pops up then I can locate the window and move it. Looking for a way to force it on the secondary monitor. Do not pop up at all on the primary. Hope that makes more sense.

    0
    Comment actions Permalink
  • Can you share the full command/code you're using? Monitor=\\.\DISPLAY2 (for example) seems to be working for me.

    0
    Comment actions Permalink
  • Process vncProcess = new Process();
    vncProcess.StartInfo.FileName = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "VNCViewer.exe");
    vncProcess.StartInfo.Arguments = "-KeepAliveResponseTimeout=9999999 -UriSuppressConnectionPrompt=TRUE -Scaling=Fit -EnableToolbar=False -Monitor=\\.\Display5 " + ipAddress;
    vncProcess.StartInfo.UseShellExecute = false;
    vncProcess.Start();

    0
    Comment actions Permalink
  • Hm, the code works for me - I did have to modify it by adding "@" to the string for the Arguments as it wouldn't compile otherwise.

    Process vncProcess = new Process();
    vncProcess.StartInfo.FileName = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "VNCViewer.exe");
    vncProcess.StartInfo.Arguments = @"-KeepAliveResponseTimeout=9999999 -UriSuppressConnectionPrompt=TRUE -Scaling=Fit -EnableToolbar=False -Monitor=\\.\DISPLAY5 " + ipAddress;
    vncProcess.StartInfo.UseShellExecute = false;
    vncProcess.Start();

    If that doesn't help, I can only assume \\.\DISPLAY5 is incorrect. You can use this modified version of my earlier code to print out all of the screens with their name, location and resolution which should help you check

    foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens)
    {
        Debug.WriteLine(screen.DeviceName + " - " + screen.Bounds.X + "," + screen.Bounds.Y + " - " + screen.Bounds.Width + "x" + screen.Bounds.Height);
    }
    0
    Comment actions Permalink
  • I have tried as much as I can think of and even tried it in a batch file as an option there but even the batch file opens it on the primary monitor.

    0
    Comment actions Permalink
  • Update, it seems if there is an actual connection the app will move to the second monitor but the initial window that says connecting to... is always on the primary monitor, is there any way to make the VNCViewer.exe open on a specific monitor and connect and view the server on that monitor?

    0
    Comment actions Permalink
  • I solved it by using the window style as minimized so it opens on the taskbar of the primary monitor then when it finally connects it does move to the Display5, thanks for your help! It seems there is no way to force VNCViewer.exe to completely launch on Display5, the windows with the connecting to... always starts on the primary monitor.

    0
    Comment actions Permalink
  • Nope, seems that it still ignores all my attempts to force all activity on the monitor that is not the primary monitor, I get a spam of popups then they finally move to the secondary monitor.

     

    This absolutely annoying window can't be forced anywhere other than the primary monitor! Why? 

    I'm creating a grid of 24 connections and the primary monitor is spammed with these popups when the refresh timer expires to force reconnects based on user set timer. This is needed because the viewer gets frozen when a device is reset and there is no way to get the client to work again without killing it and simply restarting it.

     

    0
    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post