How to get current screen's dpi


I am trying to get the scaling of current screen,in Windows 10,there are 100%,120% 150%,I find a code maybe can get it,but it does not work,anyone can help?

(dotNetClass "System.Windows.Media.VisualTreeHelper").GetDpi()


DPI is for text “size”, not for screen resolution (at least in Win 7).


So how to get current screen’ scaling?


Sorry, don’t know.
Dont have problems with win 10 or 4k monitors cause I’m not using them.
Maybe look for sysinfo in help
Or thru win native tools, why are you using max for that?

There’s sysInfo.DesktopSizeUnscaled new in 2017
and sysinfo.desktopSize from before


The reason is the text of my script runs in some Windows 10 system display are incomplete if using 125% or 150%,I need to detect whether user’s screen is scaled,then I can adjust the fonts size,the sysinfo.desktopSize maybe should not work,thanks for help.

That is a topic has a command can do it via c#,but I don’t know how to use it in maxscript

C# code:
double factor = System.Windows.PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice.M11;


I find a solution by myself,just get the value of regedit:


Thanks for help!


This are various methods:


what about GetUIScaleFactor() ? not good enough ?
delivers 1.5 at 150% scaling


It depends on what you want to do with that number. Take a look at this example:

public static System.Windows.Point GetScreenSize()
    System.Windows.Media.Matrix transform = (new HwndSource(new HwndSourceParameters())).CompositionTarget.TransformToDevice;
    return transform.Transform(new System.Windows.Point(SystemParameters.PrimaryScreenWidth, SystemParameters.PrimaryScreenHeight));