{"id":406,"date":"2021-12-10T19:53:15","date_gmt":"2021-12-10T18:53:15","guid":{"rendered":"https:\/\/www.tapper-ware.net\/blog\/?p=406"},"modified":"2021-12-10T19:53:15","modified_gmt":"2021-12-10T18:53:15","slug":"gaming-life-hacks-switch-to-second-screen-for-screencasting","status":"publish","type":"post","link":"https:\/\/www.tapper-ware.net\/blog\/gaming-life-hacks-switch-to-second-screen-for-screencasting\/","title":{"rendered":"Gaming Life hacks: Switch to second screen for Screencasting"},"content":{"rendered":"\n<p>Honestly every time I head about GeforceNow, Stadia and all the other streaming services I just smile and start Moonlight on my FireTV, my smartphone or any other Android or Windows device I have sitting around. Moonlight has made it so comfortable using your own PC as gaming cloud that it&#8217;s almost ridicoulous.<\/p>\n\n\n\n<p>Add Wake-On-Lan, Wireguard and a tiny WOL script on a Raspberry Pi and you don&#8217;t even have to keep your PC running. And waking Windows 11 up is a lot faster than any other game service I&#8217;ve tried creating a new instance for me.<\/p>\n\n\n\n<p>So, long story short: Live is good if you have a PC and you don&#8217;t need no stinking Streaming service.<\/p>\n\n\n\n<p>Sadly, there&#8217;s a but. A big one. Well, at least if you have a 32:9 screen like me connected via DisplayPort. Or if you don&#8217;t want to keep your screen running every time you stream. Again long story short: If your primary screen isn&#8217;t a 1920&#215;1080 screen connected via HDMI you&#8217;re going to have issues.<\/p>\n\n\n\n<p>Straightforward solution, add a second screen. The best way I&#8217;ve found is simply plugging in an &#8220;HDMI Dummy&#8221;, you can find plenty of those on Amazon (shouldn&#8217;t cost more than $10).<\/p>\n\n\n\n<p>Now, all you need is switch to this device when Streaming starts and you&#8217;r set.<\/p>\n\n\n\n<p>Now doing this via the Windows API is slightly complicated, but the good news is that Windows includes a braindead simple app called DisplaySwitch.exe &#8230; and detecting active streaming boils down to checking for a process alled &#8220;nvstreamer&#8221;.<\/p>\n\n\n\n<p>So what it all boils down to is this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>static bool OnSecondScreen=false;\nvar Switch = Path.Combine(Environment.SystemDirectory, \"DisplaySwitch.exe\");\nvar IsStreaming= Process.GetProcesses().Where(a => a.ProcessName.ToLower() == \"nvstreamer\").Count() > 0;\n\nif(IsStreaming &amp;&amp; !OnSecondScreen)\n   Process.Start(Switch, \"\/external\");\nelse if(!IsStreaming &amp;&amp; OnSecondScreen)\n   Process.Start(Switch, \"\/internal\");\n\nOnSecondScreen = IsStreaming;\n\n\n<\/code><\/pre>\n\n\n\n<p>Now, there are any number of ways to implement this, (I&#8217;ve got a nice little Tray Icon in my taskbar), but all you really need is the good old C# compiler that comes with Windows. Wrapping the code above in a loop you end up with<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using System;\nusing System.IO;\nusing System.Linq;\nusing System.Diagnostics;\n\nstatic class Program{\n\tstatic void Main(){\n\t\tvar OnSecondScreen=false;\n\t\tvar Switch = Path.Combine(Environment.SystemDirectory, \"DisplaySwitch.exe\");\n\t\twhile(true){\n\t\t\tvar IsStreaming= Process.GetProcesses().Where(a => a.ProcessName.ToLower() == \"nvstreamer\").Count() > 0;\n\n\t\t\tif(IsStreaming &amp;&amp; !OnSecondScreen)\n\t\t\t   Process.Start(Switch, \"\/external\");\n\t\t\telse if(!IsStreaming &amp;&amp; OnSecondScreen)\n\t\t\t   Process.Start(Switch, \"\/internal\");\n\n\t\t\tOnSecondScreen = IsStreaming;\n\t\t\t\n\t\t\tSystem.Threading.Thread.Sleep(1000);\n\t\t}\n\t}\n}<\/code><\/pre>\n\n\n\n<p>which you can save to a cs file (StreamToSecond.cs in the following example) and compile with the old C# compiler included in Windows (which is outdated, but sufficient for our purposes)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>c:\\windows\\Microsoft.NET\\Framework\\v4.0.30319\\csc.exe \/target:winexe StreamToSecond.cs<\/code><\/pre>\n\n\n\n<p>Put the EXE into your Startup folder and it will watch for NVStreamer and switch screens accordingly.<\/p>\n\n\n\n<p>Hope it helps someone ^^.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Honestly every time I head about GeforceNow, Stadia and all the other streaming services I just smile and start Moonlight on my FireTV, my smartphone or any other Android or Windows device I have sitting around. Moonlight has made it so comfortable using your own PC as gaming cloud that it&#8217;s almost ridicoulous. Add Wake-On-Lan, &hellip; <a href=\"https:\/\/www.tapper-ware.net\/blog\/gaming-life-hacks-switch-to-second-screen-for-screencasting\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Gaming Life hacks: Switch to second screen for Screencasting<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/posts\/406"}],"collection":[{"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/comments?post=406"}],"version-history":[{"count":2,"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/posts\/406\/revisions"}],"predecessor-version":[{"id":408,"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/posts\/406\/revisions\/408"}],"wp:attachment":[{"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/media?parent=406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/categories?post=406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tapper-ware.net\/blog\/wp-json\/wp\/v2\/tags?post=406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}