Jump to content

HiRes_DPI settings via Autoit3Wrapper


Recommended Posts

I have done extensive, worldwide testing and suggest the following change to the DPI section of AutoIt3Wrapper.au3.
I publish free software (updates released twice+ weekly) with 10's of thousands of users to substantiate the worldwide statement.
This covers ALL versions of Windows that support DPI scaling and is ignored by Windows version that do not support it.

Replace the entire DPI section with the following...

If $INP_RES_HiDpi = "y" Then
    Write_RC_Console_Msg("Setting DPI awareness Manifest information to true", "", "...", 0)
    FileWriteLine($hTempFile2, '<asmv3:application>')
    FileWriteLine($hTempFile2, '    <asmv3:windowsSettings>')
    FileWriteLine($hTempFile2, '        <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True/PM</dpiAware>')
    FileWriteLine($hTempFile2, '        <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2,PerMonitor</dpiAwareness>')
    FileWriteLine($hTempFile2, '    </asmv3:windowsSettings>')
    FileWriteLine($hTempFile2, '</asmv3:application>')
EndIf

As you wish.

Edited by Shark007
Link to post
Share on other sites
  • Replies 53
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Guys, you are miles ahead of me, which I have tried to explain now several times. I need to understand first what needs to happen where before I can even start considering solutions, so can we please

If you set Per-Monitor or Per-Monitor (V2) DPI Awareness then you must to resize and reposition the controls each time when receive WM_DPICHANGED message. Otherwise, the controls will match the DPI of

Posted Images

  • Developers
23 minutes ago, Shark007 said:

Replace the entire DPI section with the following...

Would be great when that really works for "Most" people as till now each proposal have had drawbacks.
Lets see if anybody can think of any issue with this or has issues when testing this mod.

Thanks for your input!
Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
  • Developers

Your proposal is basically what is already in AutoItWrapper but currently commented out due to 

Quote

; ----- reverted this change as it is giving some issues. Needs investigation

which was back in 2018 when @jpm made a proposal for some changes...., but I have no idea anymore what the issue was. 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

I didn't even look at the commented code,  but I did I know of its existence.


This one is way over my head but I want to present the idea to Jos in case it is possible.

When a user chooses to make their application DPI Aware,
The compiler automatically adjusts x, y, width, height
by multiplying those coordinates using the results of the following:

Func DPIRatio()
    _GDIPlus_Startup()
    Local $hGfx = _GDIPlus_GraphicsCreateFromHWND($MyApp) ; edit $MyApp to be your GUI
    Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0)
    _GDIPlus_GraphicsDispose($hGfx)
    _GDIPlus_Shutdown()
    If $aResult[2] = 0 Or '' Then
        Return 1
    Else
        Return $aResult[2] / 96
    EndIf
EndFunc   ;==>DPIRatio

Then the user would not need to deal with any scaling of the GUI and its controls.
I think that in the past, this is where people concluded it didn't work properly.

Edited by Shark007
Link to post
Share on other sites
  • Developers
20 hours ago, Shark007 said:

@Jos If you're considering implementing my 2 suggestions posted here, (especially including the DPIRatio Func)
I'd be more than happy to privately test any new AutoIt3Wrapper.au3 you come up with.

One thing we could consider is add an option to #AutoIt3Wrapper_Res_HiDpi. We currently have Y/N/P were "P" adds the "/PM" . So the AutoIt3Wrapper code would be:

If $INP_RES_HiDpi <> "n" Then
    FileWriteLine($hTempFile2, '    <asmv3:application>')
    FileWriteLine($hTempFile2, '        <asmv3:windowsSettings>')
    If $INP_RES_HiDpi = "p" Then
        Write_RC_Console_Msg("Setting DPI awareness Manifest information to true/PM", "", "...", 0)
        FileWriteLine($hTempFile2, '        <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True/PM</dpiAware>')
        FileWriteLine($hTempFile2, '        <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2,PerMonitor</dpiAwareness>')
    Else
        Write_RC_Console_Msg("Setting DPI awareness Manifest information to true", "", "...", 0)
        FileWriteLine($hTempFile2, '        <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True</dpiAware>')
    EndIf
    FileWriteLine($hTempFile2, '        </asmv3:windowsSettings>')
    FileWriteLine($hTempFile2, '    </asmv3:application>')
    FileWriteLine($hTempFile2, '')
EndIf

Then when you use #AutoIt3Wrapper_Res_HiDpi=p you will get the result as you want.
This way we keep the current standard behavior for "Y" to ensure we don't break anything.

Jos

 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
2 hours ago, Jos said:

One thing we could consider is add an option to #AutoIt3Wrapper_Res_HiDpi. We currently have Y/N/P were "P" adds the "/PM" . So the AutoIt3Wrapper code would be:

Then when you use #AutoIt3Wrapper_Res_HiDpi=p you will get the result as you want.
This way we keep the current standard behavior for "Y" to ensure we don't break anything.

Jos

 

True = Windows 7 -- /PM is support for Windows 8 -- PerMonitorV2 = latest versions of Windows 10 -- PerMonitor = Wimdows 8.1 and early versions of 10

Giving /PM its own status is redundant. Windows 7 ignores its presence and Windows 8 will use True unless /PM is present, then it will use PerMonitor

The code below covers all versions of Windows simultaneously if present and each version of Windows will choose what is the best option for itself.

FileWriteLine($hTempFile2, '        <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True/PM</dpiAware>')
    FileWriteLine($hTempFile2, '        <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2,PerMonitor</dpiAwareness>')

The code above is what you should be using when a user selects to enable #AutoIt3Wrapper_Res_HiDpi=y

It would be AN ABSOLUTE BONUS if you incorporated the DPIRatio Func I posted to adjust the x,y,w,h parameters of the GUI  and its contols when HiDPI is enabled. You just need to multiply each x,y,w,h by the DPIRatio result and you will have perfect support for all DPI scenario's.

Edited by Shark007
Link to post
Share on other sites
  • Moderators

Jos,

If you could incorporate a DPIRatio function as suggested - so that the user had access to known variables to use to adapt their coordinates - I would consider that a very elegant solution to the DPI problem we suffer at present. 

If you were to produce a Beta I would be happy to join @Shark007 in testing it.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites
  • Developers

I must say I am lost on how that func would need to be implemented as I assumed it is needed in the script itself, so could any of you help me understand how this could work when implemented in Autoit3Wrapper?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
  • Moderators

Jos,

Ah yes - I did not think that through enough!

Perhaps if you were to get the Wrapper to add the whole DPIRatio function to the script (using an obscure name to prevent errors) and set the results into 2 suitably-named global variables (for x and y coordinates). The user would then create his GUI and control using the preferred coordinates but using these variables to adjust them as required - something like this:

GUICreate("DPI Aware", $iX * $gAutoItWrapper_DPIAware_X, $iY * $gAutoItWrapper_DPIAware_Y, $iW * $gAutoItWrapper_DPIAware_X, $iH * $gAutoItWrapper_DPIAware_Y)

How does that sound?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

To give you some idea of how I use it, 

Global Const $iScale = DPIRatio()

Func DPIRatio()  ; match screen resolution
    _GDIPlus_Startup()
    Local $hGfx = _GDIPlus_GraphicsCreateFromHWND($SetApp)
    Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0)
    _GDIPlus_GraphicsDispose($hGfx)
    _GDIPlus_Shutdown()
    If $aResult[2] = 0 Or '' Then
        Return 1
    Else
        Return $aResult[2] / 96
    EndIf
EndFunc   ;==>DPIRatio

 

DPI_in_use.jpg

There is over 500 instances of $iScale

Edited by Shark007
Link to post
Share on other sites
  • Moderators

Shark007,

Even simpler than I thought - just the one variable needed.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites
  • Developers
5 minutes ago, Shark007 said:

To give you some idea of how I use it, 

Thanks, but let's focus on what autoit3wrapper can do for the users script, as all of this needs to happen in the users script and not in autoit3wrapper. 

@Melba23 proposal is one that could be done, but I am still wondering why it should be done by autoit3wrapper and not in the script itself?

Just trying to get my head around what it is we want to accomplish where. :)

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
  • Developers

I am sorry, but I still do not see what Autoit3wrapper can do here so you need to answer the question I asked before: isn't that something that needs to happen in the users riot at run time? ...  And what can Autoit3wrapper do here to help the user at compilation/run time?

Sorry,  but I am really lost here as stated earlier.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

It was my hope/wish that AutoWrapper could eliminate the need for the user to apply all of this scaling themselves.
Most users, enable HiDPI through Scite, see that their GUI is all F'd up and move on.
If the Wrapper could do some magic to the x,y,w,h parameters, more people would be inclined to use the DPI setting.

Edited by Shark007
Link to post
Share on other sites
  • Developers

So how would all of that work when they only compile and run the script as stand alone binary. ...  But even when using run, it is a separate instance of AutoIt3 so autoit3wrapper would have to modify the source of the script... Right?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...