Chimaera Posted May 5, 2012 Share Posted May 5, 2012 (edited) Ok what im trying to find is a way to give me the actual screen sizee.g. 15.4", 15.6", 17" etcThis will be used primarily for laptopsIs there a way to calculate it from Desktop resolution maybe?Or is it held anywhere o the pc registry etc?Ive been looking round and the only thing i could find was a reference to thisand using JSThePatriot script CompInfo "PixelsPerXLogicalInch: " "PixelsPerYLogicalInch: "and "ScreenHeight: " "ScreenWidth: "from the _ComputerGetMonitors() section it gives me96 for both the pixels per inch1920 x 1080 for the other two1920 / 96 = 201080 / 96 = 11.25This is close but not accurate and im not sure how a diagonal could be calculated from the results?Any ideas Edited May 5, 2012 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
UEZ Posted May 5, 2012 Share Posted May 5, 2012 (edited) Have in mind the size of the physical pixel.... #include <GDIPlus.au3> _GDIPlus_Startup() ConsoleWrite(ScreenSize() & " inch" & @CRLF) _GDIPlus_Shutdown() Func ScreenSize() Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND(0) $aDPI_w = DllCall($ghGDIPDll, "uint", "GdipGetDpiX", "handle", $hGraphic, "float*", 0) $aDPI_h = DllCall($ghGDIPDll, "uint", "GdipGetDpiY", "handle", $hGraphic, "float*", 0) _GDIPlus_GraphicsDispose($hGraphic) Return Round(Pixel_Distance(0, 0, @DesktopWidth, @DesktopHeight) / $aDPI_w[2], 2) EndFunc Func Pixel_Distance($x1, $y1, $x2, $y2) ;Pythagoras theorem Local $a, $b If $x2 = $x1 And $y2 = $y1 Then Return 0 $a = $y2 - $y1 $b = $x2 - $x1 Return Sqrt($a * $a + $b * $b) EndFunc ;==>Pixel_Distance Br, UEZ Edited May 5, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Chimaera Posted May 5, 2012 Author Share Posted May 5, 2012 (edited) The math in there makes my head spin, i looked up the therom on Google but geez difficult stuff That works except it returns 22.95 inch Yet my monitor is 24 inch How do i reconcile the difference? Edit and is it because im using a desktop? Edited May 6, 2012 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
czardas Posted May 6, 2012 Share Posted May 6, 2012 I'm not sure about the absolute screen dimensions but you can easily calculate the diagonal using Pythagoras' Theorem.$iDesktopDiagonal = (@DesktopWidth^2 + @DesktopHeight^2)^.5 MsgBox(0, "Desktop Dimensions", _ "Width" & @TAB & @DesktopWidth & @LF & _ "Height" & @TAB & @DesktopHeight & @LF & _ "Diagonal" & @TAB & $iDesktopDiagonal) operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
UEZ Posted May 6, 2012 Share Posted May 6, 2012 (edited) The math in there makes my head spin, i looked up the therom on Google but geez difficult stuffThat works except it returns 22.95 inchYet my monitor is 24 inchHow do i reconcile the difference?Edit and is it because im using a desktop?As I mentioned before it depends on the physical pixel size.E.g. a notebooks screen is a 17" screen and can display 1920x1080 and a monitor is a 22" with same resolution. You see calculating the pixels size at a specific DPI cannot give you the exact screen size.@czardas: look at the Pixel_Distance() function above. Br,UEZ Edited May 6, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Chimaera Posted May 6, 2012 Author Share Posted May 6, 2012 So the pixels are different sizes depending on the monitor? Did i get that right? So if i run it on a laptop on tue when i get back to work it should be right. or closer as i get its never going to be exact. If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
UEZ Posted May 6, 2012 Share Posted May 6, 2012 I do not know another way where the pixel size is saved somewhere in the system. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
KaFu Posted May 6, 2012 Share Posted May 6, 2012 (edited) There is a Vista+ WMI class called WmiMonitorBasicDisplayParams. This one comes pretty close for my primary display (reports 27,15" for my 27"), but sadly it completely fails for my secondary (TV) display (reports 28,9" for my 47")._WmiMonitorBasicDisplayParams() Func _WmiMonitorBasicDisplayParams() Local $strcomputer = "." Local $objWMIServiceWMI = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!" & $strcomputer & "rootWMI") If IsObj($objWMIServiceWMI) Then ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa394535%28v=vs.85%29.aspx $WMIWmiMonitorID = $objWMIServiceWMI.ExecQuery("SELECT * FROM WmiMonitorBasicDisplayParams WHERE Active='True'") For $objComputer In $WMIWmiMonitorID ConsoleWrite($objComputer.MaxHorizontalImageSize & @CRLF) ConsoleWrite($objComputer.MaxVerticalImageSize & @CRLF) ConsoleWrite((Pixel_Distance(0, 0, $objComputer.MaxHorizontalImageSize, $objComputer.MaxVerticalImageSize) / 2.54) & @CRLF & @CRLF) Next EndIf EndFunc ;==>_WmiMonitorBasicDisplayParams Func Pixel_Distance($x1, $y1, $x2, $y2) ;Pythagoras theorem Local $a, $b If $x2 = $x1 And $y2 = $y1 Then Return 0 $a = $y2 - $y1 $b = $x2 - $x1 Return Sqrt($a * $a + $b * $b) EndFunc ;==>Pixel_Distance Edited May 6, 2012 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Chimaera Posted May 6, 2012 Author Share Posted May 6, 2012 Many thanks for the help guys If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
czardas Posted May 7, 2012 Share Posted May 7, 2012 (edited) @czardas: look at the Pixel_Distance() function above. LOL I didn't recognize it. I never knew about the function Sqrt(), who would have thought it! Edited May 7, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Chimaera Posted May 8, 2012 Author Share Posted May 8, 2012 A little update I did some testing at work on a number of laptops and one desktop on kafu's suggestion And these were the results Desktop MaxHorizontalImageSize 34 / MaxVerticalImageSize 27 / Resolution 1280 x 1024 / Result 17.11 Actual = 34.1 | 27.3 [17.0"] Laptop MaxHorizontalImageSize 31 / MaxVerticalImageSize 19 / Resolution 1366 x 768 / Result 15.35 Actual = 34.6(cm)| 19.8(cm) [15.6"] MaxHorizontalImageSize 33 / MaxVerticalImageSize 21 / Resolution 1280 x 800 / Result 15.41 Actual = 33.1(cm) | 20.8(cm) [15.4"] MaxHorizontalImageSize 33 / MaxVerticalImageSize 21 / Resolution 1280 x 1024 / Result 15.41 Actual = 33.1(cm)| 20.9(cm) [15.4"] MaxHorizontalImageSize 38 / MaxVerticalImageSize 21 / Resolution 1600 x 900 / Result 17.11 Actual = 38.2(cm) | 21.5(cm) [17.3"] MaxHorizontalImageSize 34 / MaxVerticalImageSize 19 / Resolution 1366 x 768 / Result 15.35 Actual = 34.4(cm) | 19.5(cm) [15.6"] MaxHorizontalImageSize 34 / MaxVerticalImageSize 19 / Resolution 1366 x 768 / Result 15.35 Actual = 34.4(cm) | 19.5(cm) [15.6"] MaxHorizontalImageSize 37 / MaxVerticalImageSize 23 / Resolution 1440 x 900 / Result 17.17 Actual = 36.8(cm) | 23.1(cm) [17.0"] Thought i would post them just so you guys can see them If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
UEZ Posted May 8, 2012 Share Posted May 8, 2012 (edited) Thanks for the testing and results. Overall a good approximation! Br, UEZ Edited May 8, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Chimaera Posted May 8, 2012 Author Share Posted May 8, 2012 Im probably going to have to have a if its between these figures then call it 15.4 etc etc scenario to make it workable in the end. But ill run some more tests first If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now