Jump to content

Search the Community

Showing results for tags 'dpi aware'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office


  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Member Title




Found 2 results

  1. Since this thread is getting long, I thought I'd copy all the relevant information to the 1st post. Three different types of DPI Aware'ness are made available from Microsoft. 1. System Aware (introduced with Windows Vista) 2. Per Monitor Aware (Introduced with Windows 8.1) 3. Per Monitor Aware V2 (Introduced with Windows 10 1703) Method #1 - Programmatically - Only available for Windows 8.1 and 10 ; For values available to Windows 10 users - https://docs.microsoft.com/en-gb/windows/win32/hidpi/dpi-awareness-context If @OSVersion = 'WIN_10' Then DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -2) If @OSVersion = 'WIN_81' Then DllCall("User32.dll", "bool", "SetProcessDPIAware") ; *** Microsoft warns that these entries need to be executed before the GUI is created *** ;This is the only reason they recommend using the Manifest method over the programmatic method When using the above code, Windows 10 and 8.1 will recognize your compiled app as DPI System Aware. Method #2 - using Manifest entries - Available for all Windows starting with Vista, up to current and future releases of Windows. Using #AutoIt3Wrapper_Res_HiDpi=Y will set your compiled app as DPI System Aware (Win Vista, 7, 8.1, 10). For Windows 8.1, using the Manifest method is the only way to have Per Monitor Aware. Follow this link to learn how to create Per Monitor Aware and Per Monitor Aware V2 apps for Windows 10. Learn how here *** This is the Microsoft recommended method of creating a DPI Aware application *** *** If you choose either method above, you will still need to deal with the GUI itself and all of its Controls. *** Being DPI Aware only deals with text. The simplest method to achieve this is to adapt the code below into your script. Global $iScale = RegRead("HKCU\Control Panel\Desktop\WindowMetrics", "AppliedDPI") / 96 GUICreate("DPI test", 200 * $iScale, 100 * $iScale) GUICtrlCreateButton("Ima Button", 35 * $iScale, 115 * $iScale, 55 * $iScale, 21 * $iScale) ; For reference, I have a single App with 579 occurances of $iScale ; Also know; I've had to make some small x,y adjustments to keep the GUI looking good but nothing drastic. ; Be sure to test your compiled app at 125% and at 200%. This is how I found small descrepancies requiring x,y adjustments. more importantly, this registry value can be had, programmatically and in my opinion, more efficiently With 4k monitors becoming a norm, this should set you well on your way to creating a DPI Aware applications that looks good on any system.
  2. Been struggling with this one for a while. when I do a _screencapture_capture call on a high resolution monitor (like my surface book) it gives me an image that has 2 problems: 1. its in the wrong location on the screen and 2. it gives me a picture that is larger than the area of the screen I selected, though it only has the content of what I selected. --------------------------- I was able to easily fix problem #1 by manually adjusting the x y coordinates to compensate for the amount of DPI scale I have. for instance if I'm 200% zoomed in the code looks like this: Local $bmp = _ScreenCapture_Capture("", $iX1*2, $iY1*2, $iX2*2, $iY2*2, false) it's problem #2 that is the big problem. I'd like to attach a screen shot of what I'm talking about (see capture.png) --------------------------- Now I basically understand why this is happening. ScreenCapture grabs each pixel of the screen. This screen, being a high resolution, when its zoomed in adds up several pixels to make one on the screen. This is a problem for me because I'm taking images of the screen and later looking for those exact images on the screen. if everything is blown up by an indeterminate amount (in my case 2x) then those images can't be found later on. Does anyone know what I can do? I tried resizing the images back down to no avail. _GDIPlus_ImageResize and _GDIPlus_ImageScale don't work because they don't compress the pixels correctly. quality is lost. and the exact image isn't preserved, so I can't search for it later. (see capture1.png) Anyway, I'm about to give up, been on this problem for too long! does anyone know what I can do? Seems to me that the ideal solution would be to eventually have autoit add an argument to _screencapture_capture that lets you specify a DPI scale amount or something. that can be pulled from the registry at HKEY_CURRENT_USER\control panel\desktop\windowmetrics\appliedDPI. But in the meantime, does anyone have any suggestions for how I can make my program compatible with 4k resolution monitors? I either need to take the screen capture like normal, then scale it down appropriately without losing quality, or I need to capture the screen in the first place like the human sees it. But I don't know how to do that either. I'll post my relevant code here: (in my project I call ScreenCapture_DPI_Aware) #include <Security.au3> Func _GetAppliedDPI()   Local $aArrayOfData = _Security__LookupAccountName(@UserName)   If IsArray($aArrayOfData) Then   ;msgbox(64, "SID String = ", $aArrayOfData[0] & @CRLF)   ;msgbox(64, "Domain name = ", $aArrayOfData[1] & @CRLF)   ;msgbox(64, "SID type = ", _Security__SidTypeStr($aArrayOfData[2]) & @CRLF)     ;Local $AppliedDPI = RegRead("HKEY_USERS\" & $aArrayOfData[0] & "\Control Panel\Desktop\WindowMetrics", "AppliedDPI") Local $AppliedDPI = RegRead("HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics", "AppliedDPI")     return $AppliedDPI   EndIf EndFunc Func GetScale()   $applied = _GetAppliedDPI()   if $applied == "" then     return 1   else     return $applied / 96   EndIf EndFunc Func ScreenCapture_Capture_DPI_Aware($sBMP_Path, $iX1, $iY1, $iX2, $iY2, $bool)   $R = GetScale() ;Raito   Local $bmp = _ScreenCapture_Capture($sBMP_Path, $iX1*$R, $iY1*$R, $iX2*$R, $iY2*$R, $bool) ;Scaling didn't work: ;_ScaleImage($bmp, $sBMP_Path, abs($iX2 - $iX1), abs($iY2 - $iY1), $R)   ;return _ScreenCapture_Capture($sBMP_Path, $iX1*$R, $iY1*$R, $iX2*$R, $iY2*$R, $bool) EndFunc ;Func _ScaleImage($bmp, $outimage, $w, $h, $scale) ; _GDIPlus_Startup() ;Get the encoder of to save the resized image in the format you want. ; Local $Ext = StringUpper(StringMid($outimage, StringInStr($outimage, ".", 0, -1) + 1)) ; $CLSID = _GDIPlus_EncodersGetCLSID($Ext) ; code found here : https://www.autoitscript.com/autoit3/docs/libfunctions/_GDIPlus_ImageSaveToStream.htm ; Local $sImgCLSID = _GDIPlus_EncodersGetCLSID("png") ;create CLSID for a JPG image file type ; Local $tGUID = _WinAPI_GUIDFromString($sImgCLSID) ;convert CLSID GUID to binary form and returns $tagGUID structure ; Local $tParams = _GDIPlus_ParamInit(1) ;initialize an encoder parameter list and return $tagGDIPENCODERPARAMS structure ; Local $tData = DllStructCreate("int Quality") ;create struct to set JPG quality setting ; DllStructSetData($tData, "Quality", 100) ;quality 0-100 (0: lowest, 100: highest) ; Local $pData = DllStructGetPtr($tData) ;get pointer from quality struct ; _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) ;add a value to an encoder parameter list ; Local $gbmp = _GDIPlus_BitmapCreateFromHBITMAP($bmp) ; _WinAPI_DeleteObject($bmp) ; Local $gsbmp = _GDIPlus_ImageResize($gbmp, $w * $scale, $h * $scale) ;Local $ext = _GDIPlus_EncodersGetCLSID("PNG") ; _GDIPlus_ImageSaveToFileEx($gsbmp, $outimage, $sImgCLSID) ; _GDIPlus_BitmapDispose($gbmp) ; _GDIPlus_BitmapDispose($gsbmp) ; _GDIPlus_Shutdown() ;EndFunc Thanks for any help you can give me!!!
  • Create New...