I would like to be able to set "Extend my Windows desktop onto this monitor" via code. A PowerShell script would be ideal. WMI seems the way forward but I have zero knowledge in WMI.
相关问题
- How to Debug/Register a Permanent WMI Event Which
- Inheritance impossible in Windows Runtime Componen
- How can I do variable substitution in a here-strin
- how to get running process information in java?
- Is TWebBrowser dependant on IE version?
相关文章
- 在vscode如何用code runner打开独立的控制台窗口,以及设置好调试模式时窗口的编码?
- C#调用PowerShell的问题
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- EscapeDataString having differing behaviour betwee
- Bundling the Windows Mono runtime with an applicat
- Windows 8.1 How to fix this obsolete code?
Here is my AutoIt-Script for switching monitors as my ATI graphics card doesn't allow me to have 3 monitors active at the same time. I have 2 monitors attached and a TV. This script is doing what VonC's script does but in a more effective and faster way.
Just replace "SAMSUNG" with your third monitors/tvs name and you're all set! As you surely know you can convert it to an executable which runs on any machine even without AutoIt installed.
I had to made some small modifications to get VonC's script to work on my machine. It is now a little more generic.
This sort of operation is not directly accessible from PowerShell in the sense that there is not a .NET interface to these settings. A lot of core OS stuff is unmanaged code which can only be manipulated via win32 API calls. While you may be on to something with WMI, I searched for a while and wasn't able to find a satisfactory WMI class which is able to manipulate this setting.
The next step would be to modify the registry directly. It looks like the setting lies under HKLM:\system\CurrentControlSet\control\video--somewhere. I believe it's the one called "Attach.ToDesktop".
This is a partial solution, so I'm marking as community wiki answer.
I'm not certain this is the right registry key, and I don't have a system on which I can test multi-monitor at the moment. The purpose of this is to determine which is the primary controller, and then it outputs the value of the Attach.ToDesktop key.
I've made a cleaner version that does not use sendkeys.
I have only tested this on a newly installed computer.
Windows 7, 8 and 10 are supposed to come with a small program that does exactly this: displayswitch.exe. This page lists the following parameters:
For a one-click solution to the problem posed, simply create a *.bat-file containing the single line
and save it to your desktop.
[I tested this on Windows 8.1, and it has been confirmed to work on Windows 10.]
One first possible solution is... through the GUI (but without user interaction)
VB script (also described here but in Autoit language):
In Autoit, that would be: