6

I have a 14" 1920×1080 laptop and a 24" 1920×1200 screen. The pixel density difference is huge.

When I'm using the large screen as a main one and laptop as an additional screen, I'd like to have the smaller one set to 150% scaling so that I can use it comfortably. But when I'm away from my desk and the external screen is disconnected, I'd like the laptop to automatically switch to 100% scaling to maximize desktop area.

How can I make Windows switch DPI scaling automatically when external screens are connected or disconnected?

I'm okay with using 3rd party software if it's necessary, but I'd rather stick to built-in features of Windows.

I'm using Windows 10 Pro Version 1703.

8
  • I don't think there is any Windows feature to do what you want. How badly do you want it? You might be able to do something with powershell, but it will likely be monstrously over complicated.
    – ben_re
    Commented Jul 17, 2017 at 18:42
  • 1
    @lifesaspanner Well, I've priced my need for it at 50 reputation points paid with a bounty ;) It could be useful for me, but I don't have a burning need for it.
    – gronostaj
    Commented Jul 17, 2017 at 19:04
  • @gronostaj I'm currently working on a similar project using batch files to call powershell scripts, but mine concerns monitor brightness. I should have it nailed down by early next week, so if there isn't an answer at that point I will at least share my research and process with you. This should absolutely be able to be done through powershell, but it will be a pain in your behind.
    – jcam3
    Commented Jul 19, 2017 at 14:10
  • @jcam3 That may be interesting to look at! If that's of any use to you, ScreenBright can control screen brightness of external displays via DDC/CI and has command-line interface. I'm using it with SE-TrayMenu to control brightness from the notification area.
    – gronostaj
    Commented Jul 19, 2017 at 14:21
  • 1
    @gronostaj I'll have to take a closer look at that application, looks interesting. What I'm trying to do is basically a 3-5 second brightness reduction looped every 20 minutes or so. The idea is to have an automatic non-intrusive reminder to take a screen break now and then for eye strain relief. Has potential for a pomodoro-style application too, but have to get it working first.
    – jcam3
    Commented Jul 19, 2017 at 14:39

3 Answers 3

1

You can't change DPI scaling automatically because it requires you to logoff and logon.

Here's a good thread on using powershell to set the DPI registry key and toggle back and forth between two DPIs a little quicker. You still have to logoff, and the script automates that.

https://stackoverflow.com/questions/10365394/change-windows-font-size-dpi-in-powershell

If you want to expand on this, here is information about reading monitor information with Powershell: https://blogs.technet.microsoft.com/heyscriptingguy/2013/10/03/use-powershell-to-discover-multi-monitor-information/

And, here is information about changing the registry key of a specific user. This will be needed because if you run your script while you are not logged on, or during startup your registry hive will not be loaded. https://www.pdq.com/blog/modifying-the-registry-of-another-user/

Combine it all together with some ingenuity and you could schedule this script to run on logoff and on computer startup. The tricky part is that you will always have to be doing a new logon to get the new settings to take effect and to me, that is the biggest drawback about this.

Now, a better solution might be to change the actual display resolution which can be done without logging off: https://blogs.technet.microsoft.com/heyscriptingguy/2010/07/07/hey-scripting-guy-how-can-i-change-my-desktop-monitor-resolution-via-windows-powershell/

A lot of programs do not function properly with a non-standard DPI, and so if you ask me, changing the display resolution is a better solution.

So there you have it. All the resources to create your new script to automate this. Now you can see if you can get anybody over at http://stackoverflow.com to help you with it. :)

6
  • 4
    “You can't change DPI scaling automatically because it requires you to logoff and logon.” That’s no longer true. It only applies to legacy scaling. Windows 10 can change scaling on the fly.
    – Daniel B
    Commented Jul 22, 2017 at 17:44
  • Sorry but you are wrong about this. Windows always adjusts the DPI but then indicates you have to sign-out to complete the change. Try it, you'll see. Just confirmed it myself on Windows 10. Commented Jul 22, 2017 at 18:15
  • 5
    More specifically, the message reads: “Some apps won’t respond to scaling until you sign out.” – And that’s how it is. It scales instantly. Most programs respond correctly. Few do not.
    – Daniel B
    Commented Jul 22, 2017 at 18:46
  • Fair enough. But, I have been unable to locate an API to modify DPI and I am only assuming it is because of the requirement to logoff and logon (even if only for certain apps) and the incompatibility that some programs do exhibit. Commented Jul 23, 2017 at 18:01
  • Logging off is not an option for me, it would interrupt my workflow. I want DPI to change seamlessly when screen setup changes.
    – gronostaj
    Commented Jul 25, 2017 at 8:50
0

Here is how to do it.

Create a myswitch.bat text file like this one:

@echo off

:: Check if an external monitor is connected
wmic path Win32_DesktopMonitor get Availability | findstr /C:"2"

if %errorlevel%==0 (
   :: External monitor is connected, set scaling to 150%
   control.exe /name Microsoft.Display /page pageDPI
   control.exe /name Microsoft.Display /page pageAdvancedSettings /cmd ChangeDPI 150
) else (
   :: External monitor is not connected, set scaling to 100%
   control.exe /name Microsoft.Display /page pageDPI
   control.exe /name Microsoft.Display /page pageAdvancedSettings /cmd ChangeDPI 100
)
  • Open the task scheduler.

  • Add a task:

     General tab:
     Name: "DPI Switch"
     User Account: select "Administrator"
    
     Triggers tab:
     New:
     Begin the task: "On an event"
     Log: "System"
     Source: "Display"
     Event ID: "10" (for display connect) or "11" (for display disconnect)
     New:
     Begin the task: "On an event"
     Log: "System"
     Source: "Display"
     Event ID: "11" (for display disconnect) or "10" (for display connect)
    
     Actions tab:
     New:
     Action: "Start a program"
     Program/script: enter the path to the "myswitch.bat" file, e.g. C:\Users\<username>\Documents\myswitch.bat
    

Click OK and voila.

2
  • This seems to just open the correct settings dialogue but not change anything? I am on Windows 11 Pro 21H2 22000.1455. Sry about the bounty, I was quite ill last week, will create another if this turns out working.
    – jan-glx
    Commented Feb 4, 2023 at 13:17
  • This could be combined with darwish's answer
    – jan-glx
    Commented Jun 28, 2023 at 22:17
0

dpiSwitcher

... is a small .exe that you can dowload/install & forget about but that will automagically fix your internal monitors dpi-scaling just the way you like it whenever you are without/back with your external monitor(s).

I wrote dpiSwitcher based on imniko's work and more importantly Sahil Singh's work (See also this answer).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .