Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smarter monitor management. #32

Open
Entropic-Fiesta opened this issue Oct 3, 2024 · 4 comments
Open

Smarter monitor management. #32

Entropic-Fiesta opened this issue Oct 3, 2024 · 4 comments

Comments

@Entropic-Fiesta
Copy link

A way to have the virtual monitor dynamically turn on and off depending on external decencies.

For example while i'm normally using my computer it stays off.

Opening steam VR turns the virtual display on, so it's only in use when it's visible to the user.
Closes again when closing Steam VR.

Improves UX automatically.

@ge9
Copy link
Owner

ge9 commented Oct 3, 2024

Thanks for the issue.
I found it's possible to turn on and off IddSampleDriver by executing following commands in admin PowerShell:

Enable-PnpDevice ROOT\DISPLAY\0000 -Confirm:$false
Disable-PnpDevice ROOT\DISPLAY\0000 -Confirm:$false

(The device ID may change, but probably this is often correct)
So I think we don't have to provide such a function in IddSampleDriver but can realize such a function using some external automation tool like AutoHotkey.

@Entropic-Fiesta
Copy link
Author

Brilliant, however i'm unsure how to implement this into a script.
Or a simple file I can run to execute the command.
Saving the file as a .ps1 never runs the file even as admin, only running it manually though a PowerShell instance gets the command to correctly function.

@ge9
Copy link
Owner

ge9 commented Oct 4, 2024

powershell.exe -command start-process 'powershell.exe' '-command Enable-PnpDevice ROOT\DISPLAY\0000 -Confirm:$false' -Verb runas

This command runs the previous command as administrator, but of course with UAC dialog, which you may not want.
Probably it's better to implement some background program.
I tried writing it. This AutoHotkey program, if run with admin privilege, turns on IddSampleDriver when Notepad is open and turns it off when Notepad is closed.

#SingleInstance, Force

loop, {
loop, {
    if WinExist("ahk_class Notepad") {
        Run powershell -command Enable-PnpDevice ROOT\DISPLAY\0000 -Confirm:$false,,Hide
        break
    }
    Sleep, 100
}
Sleep, 100
loop, {
    if !WinExist("ahk_class Notepad") {
        Run powershell -command Disable-PnpDevice ROOT\DISPLAY\0000 -Confirm:$false,,Hide

        break
    }
    Sleep, 100
}
Sleep, 100
}

Here I used window class to detect Notepad window.

Sometimes it's not so easy to detect only specific windows you want, and I don't know how steam VR windows works, but it's probably possible.

@Entropic-Fiesta
Copy link
Author

Brilliant!

Got it working.

#SingleInstance, Force

loop, {
loop, {
    if WinExist("ahk_exe C:\Program Files (x86)\Steam\steamapps\common\SteamVR\bin\win64\vrmonitor.exe") {
        Run powershell -command Enable-PnpDevice ROOT\DISPLAY\0000 -Confirm:$false,,Hide
        break
    }
    Sleep, 100
}
Sleep, 100
loop, {
    if !WinExist("ahk_exe C:\Program Files (x86)\Steam\steamapps\common\SteamVR\bin\win64\vrmonitor.exe") {
        Run powershell -command Disable-PnpDevice ROOT\DISPLAY\0000 -Confirm:$false,,Hide

        break
    }
    Sleep, 100
}
Sleep, 100
}

You'll just need to create a shortcut and place it into the windows start up folder with admin rights.
:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants