I often boot my Windows 7 PC with the attached KVM switch focused on another computer. When I switch to the booted PC, the display resolution is wrong (and the second attached monitor is not detected).
I can correct this by right-clicking the desktop, choosing Screen Resolution
and clicking Detect
. This makes Windows detect attached displays and adjust to the most optimal resolution.
I would like to write a small utility to do this automatically. Which Win32 API call or C# object should I use?
You can try:
This will get you half-way there:
Execute: control.exe desk.cpl,Settings,@Settings
That will bring up the Screen Resolution panel directly.
I might also suggest a scripting tool like http://en.wikipedia.org/wiki/Windows_Script_Host And write a utility that'll open the panel and click the button.
Barring that it's possible that the control panel directly calls into a windows .dll which you can load and invoke in code directly, but that would require some sleuthing to detect. (you can start by running the .cpl in a debugger and see what happens when you click the detect).
Why not just use Do It Again and write a macro that resets the resolution for you by recording your mouse and keyboard actions?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With