itsmikethetech / Virtual-Display-Driver

Add virtual monitors to your windows 10/11 device! Works with VR, OBS, Sunshine, and/or any desktop sharing software.
https://vdd.mikethetech.com/
3.59k stars 148 forks source link

On reboot Virtual display makes itself my “Main Monitor” in display settings #31

Open Night1099 opened 10 months ago

Night1099 commented 10 months ago

Because of this all windows open on the display i cant see and i have to use remote desktop or disable device temporarily to use computer on every startup

windows 11 hdr most recent version

Ckleinloog commented 9 months ago

i encountered the same behavior. After successfully installing the iddsampledriver HDR and using Moonlight, the Display Settings are not sticking. By that I mean, I set "PC Screen Only" using Win+P after the gaming session and shutdown. On reboot where you enter the Win11 PIN, the laptop screen is black and the display is on external screen. So I have to blind type my PIN and use Win+P blind to cycle to show my laptop screen again.

I tried several times and cant get it the setting to stick. Any Ideas please if there are settings that I missed to change this behavior or is a bug? Many thanks.

Edit: Asus TUF F15 - RTX3050 (31.0.15.5123) - Win11 22H2

sukuoru commented 6 months ago

I also have this issue. Clean install of Windows 11, got a virtual display set up and working with Sunshine. However, on restart I see a black screen, and can see the LED for Windows Hello flashing. Once logged in, still seeing a black screen. Win+P will switch, and it seems like it's coming out of 640x480 or another low resolution on switch. I should note that I am in the normal profile when I shutdown, but on startup it behaves as if the Virtual Display is on, and set as the main display. After changing profiles with a bat file, or Win+P, it shows my Internal Display as the main monitor.

A workaround is to create a .bat file in my startup folder ( Win+R then shell:startup ) to load the "Default" profile from MonitorSwitcher. Example:

@ECHO OFF
C:\Users{Your User Here}\Desktop\Games\GameStreaming\MonitorSwitcher\MonitorSwitcher.exe -load:C:\Users{Your User Here}\AppData\Roaming\MonitorSwitcher\Profiles\desktop.xml

If the username has spaces, you can use: "C:\Users{Your User Here}\Desktop\Games\GameStreaming\MonitorSwitcher\MonitorSwitcher.exe" "-load:C:\Users{Your User Here}\AppData\Roaming\MonitorSwitcher\Profiles\desktop.xml"

Hoping this information can help others, but also lead to a fix.

zjoasan commented 6 months ago

The way i would solve this is to disable the device before shutdown. I've been playing with some powershell-scripting, and using two modules from powershell gallery I've built some scripts to enable/disable the device, change resolution / toogle hdr /change orientation. These scripts should be available under dynamic-edid branch: https://github.com/itsmikethetech/Virtual-Display-Driver/tree/DynamicEdid/scripts These scripts have a "MTT1337" as the identifier(as in the coming version of the driver), you have to edit the scripts and replace he "MTT1337" with "LNX0000" if my memory serves me right. Then you add a login/out script that runs toogleVDD script.

Alternatively if you just need the tooglePWR, that script for current stable version is located in Community scripts here on github, I do believe it's for the current Release version.

Good luck

bud3699 commented 6 months ago

I'll try reproduce the issue, I believe it was caused by multiple drivers being installed onto the system. Cant remember, if i can reproduce the issue it would help a lot in order to identify the problem

Jocke you can help me with that if you want

Ckleinloog commented 6 months ago

The way i would solve this is to disable the device before shutdown. I've been playing with some powershell-scripting, and using two modules from powershell gallery I've built some scripts to enable/disable the device, change resolution / toogle hdr /change orientation. These scripts should be available under dynamic-edid branch: https://github.com/itsmikethetech/Virtual-Display-Driver/tree/DynamicEdid/scripts These scripts have a "MTT1337" as the identifier(as in the coming version of the driver), you have to edit the scripts and replace he "MTT1337" with "LNX0000" if my memory serves me right. Then you add a login/out script that runs toogleVDD script.

Alternatively if you just need the tooglePWR, that script for current stable version is located in Community scripts here on github, I do believe it's for the current Release version.

Good luck

I have run the toggle-VDD.ps1 script as a Do/Undo command when Sunshine starts/stops and can confirm this is a good workaround for now. I dont have enough IT knowledge to figure out how run the script on logon/logoff and bypass all WIn11 security features. Thank you

IamBobble commented 4 months ago

The way i would solve this is to disable the device before shutdown. I've been playing with some powershell-scripting, and using two modules from powershell gallery I've built some scripts to enable/disable the device, change resolution / toogle hdr /change orientation. These scripts should be available under dynamic-edid branch: https://github.com/itsmikethetech/Virtual-Display-Driver/tree/DynamicEdid/scripts These scripts have a "MTT1337" as the identifier(as in the coming version of the driver), you have to edit the scripts and replace he "MTT1337" with "LNX0000" if my memory serves me right. Then you add a login/out script that runs toogleVDD script. Alternatively if you just need the tooglePWR, that script for current stable version is located in Community scripts here on github, I do believe it's for the current Release version. Good luck

I have run the toggle-VDD.ps1 script as a Do/Undo command when Sunshine starts/stops and can confirm this is a good workaround for now. I dont have enough IT knowledge to figure out how run the script on logon/logoff and bypass all WIn11 security features. Thank you

I did this however im running into a problem where sunshine is unable to perform the script: Im unsure what the issue is a I have basic knowledge in this. Keep in mind i renamed the script since I had to correct Virtual Driver to IddSample Driver HDR.

[2024:07:06:00:30:26]: Info: Executing Do Cmd: [powershell.exe -executionpolicy bypass -file \"C:\Program Files\Sunshine\scripts\toggleVDD.ps1\"]
[2024:07:06:00:30:26]: Info: powershell.exe -executionpolicy bypass -file \"C:\Program Files\Sunshine\scripts\toggleVDD.ps1\" running with PID 13864
[2024:07:06:00:30:26]: Error: [powershell.exe -executionpolicy bypass -file \"C:\Program Files\Sunshine\scripts\toggleVDD.ps1\"] failed with code [-196608]
[2024:07:06:00:30:30]: Info: Executing Do Cmd: [powershell.exe -executionpolicy bypass -file \"C:\Program Files\Sunshine\scripts\toggleVDD.ps1\"]
[2024:07:06:00:30:30]: Info: powershell.exe -executionpolicy bypass -file \"C:\Program Files\Sunshine\scripts\toggleVDD.ps1\" running with PID 16468
[2024:07:06:00:30:30]: Error: [powershell.exe -executionpolicy bypass -file \"C:\Program Files\Sunshine\scripts\toggleVDD.ps1\"] failed with code [-196608]

Heres the script I use:

 # Self-elevate the script if required
 if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
    if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
        $CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
        Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
        Exit
    }
 }

$device = get-pnpdevice -class Display -FriendlyName 'IddSampleDriver Device HDR' -ErrorAction SilentlyContinue

if ($device) {
    if ($device.Status -eq 'OK') {
        Write-Host "Disabling device"; $device | disable-pnpdevice -Confirm:$false
    } else {
        Write-Host "Enabling device"; $device | enable-pnpdevice -Confirm:$false
    }
} else {
    Write-Warning "Device not found"
}
IamBobble commented 4 months ago

figured it out and heres how since it took me ages lmao.

  1. download MultiMonitorTool.exe
  2. Put it somewhere, I put it in the IddSampleDriver folder which i kept in my C: drive.
  3. in that folder create a txt file and put:
    @echo off
    cd C:\<PathToMultiMonitorToolFolder>
    MultiMonitorTool.exe /disable <MonitorID of IddSampleDriver>
    MultiMonitorTool.exe /enable <MonitorID of your Laptop Display>
    MultiMonitorTool.exe /SetPrimary <MonitorID of your Laptop Display>
  4. save it as a .bat, I put it in the same folder.
  5. Go to task scheduler and schedule it to auto run on startup.
  6. problem solved

If anyone has a better solution lmk cause I have a feeling this isn't optimal but its what I got to work. Thank you to those above since I basically just copied their idea.

Here you'll find a list of what ever else you might want to add for your needs

https://www.nirsoft.net/utils/multi_monitor_tool.html

zjoasan commented 4 months ago

Yeah that will work too, I'm sorry about the "miss alignment of names" in script and actual driver. The script were mostly based on the next release, then I had to regress the name, then I had to change again.. I'm unsure where i left it laying. While I believe we are coming to a new release shortly, I will make sure the scripts will be compatible.

PS. There is a logon-enable / logoff-disable, tweak i got working. But I'm unsure if it will be in the coming release.

IamBobble commented 3 months ago

update: I have gotten the toggleVDD script to finally work so that the driver is disabled normally and is only enabled when there is a sunshine/moonlight stream active, however due to the errors I got from the original script

2024:07:06:00:30:26]: Info: Executing Do Cmd: [powershell.exe -executionpolicy bypass -file \"C:\Program Files\Sunshine\scripts\toggleVDD.ps1\"] [2024:07:06:00:30:26]: Info: powershell.exe -executionpolicy bypass -file \"C:\Program Files\Sunshine\scripts\toggleVDD.ps1\" running with PID 13864 [2024:07:06:00:30:26]: Error: [powershell.exe -executionpolicy bypass -file \"C:\Program Files\Sunshine\scripts\toggleVDD.ps1\"] failed with code [-196608] [2024:07:06:00:30:30]: Info: Executing Do Cmd: [powershell.exe -executionpolicy bypass -file \"C:\Program Files\Sunshine\scripts\toggleVDD.ps1\"] [2024:07:06:00:30:30]: Info: powershell.exe -executionpolicy bypass -file \"C:\Program Files\Sunshine\scripts\toggleVDD.ps1\" running with PID 16468 [2024:07:06:00:30:30]: Error: [powershell.exe -executionpolicy bypass -file \"C:\Program Files\Sunshine\scripts\toggleVDD.ps1\"] failed with code [-196608]

I now use this script which was ngl edited by chatgpt, i apologize if this feels like spam but felt like I should share what I found for others going through this issue.

config.do_cmd + check run as elevated

powershell.exe -ExecutionPolicy Bypass -File "C:\path\to\ToggleVDD.ps1"

here's the script:

# Self-elevate the script if required
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
    if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
        $CommandLine = "-File `"$($MyInvocation.MyCommand.Path)`" $($MyInvocation.UnboundArguments)"
        Start-Process -FilePath PowerShell.exe -Verb RunAs -ArgumentList $CommandLine
        Exit
    }
}

try {
    $device = Get-PnpDevice -Class Display -FriendlyName 'IddSampleDriver Device HDR' -ErrorAction Stop

    if ($device.Status -eq 'OK') {
        Write-Host "Disabling device"
        Disable-PnpDevice -InstanceId $device.InstanceId -Confirm:$false
    } else {
        Write-Host "Enabling device"
        Enable-PnpDevice -InstanceId $device.InstanceId -Confirm:$false
    }
} catch {
    Write-Error "An error occurred: $_"
}

just run the script once beforehand + check device manager for confirmation and you should be good to go

zjoasan commented 3 months ago

Hopefully in a coming update the script will be signed, which will make the windows default setting to allow remotely sign executable to run without issues, removing the need to change the execution policy.