hoppfrosch / WindowPadX

Enhancements on original WindowPad (by Lexikos)
http://hoppfrosch.github.com/WindowPadX
224 stars 42 forks source link

Fix for DPI scaling #23

Open johannes-z opened 5 years ago

johannes-z commented 5 years ago

When I enable DPI scaling > 100%, the positioning and the window size is wrong. Does somebody have a fix for that?

johannes-z commented 5 years ago

I found this reddit thread (https://www.reddit.com/r/Batch/comments/4665jq/how_to_change_windows_10_display_scaling_via/) explaining how to read per monitor dpi values. AHK can only read the primary display's dpi value...

alapo commented 5 years ago

@johannes-z were you able to come up with a fix?

I am getting the same issue with 2 1920x1080p monitors where WindowPad is not moving the window into the corner perfectly.

img

johannes-z commented 5 years ago

@alapo Hi, I think this is another problem. And no, I did not find a universal solution for windows without borders. I tried a few variants by now, but couldn't find an option that works for all types of windows...

BjAlvestad commented 4 years ago

To make WPXA_Move size the windows correctly on monitors with different DPI than the main monitor, call: originalContext := DllCall("SetThreadDpiAwarenessContext", "ptr", -3, "ptr") at the top of WPXA_Move and DllCall("SetThreadDpiAwarenessContext", "ptr", originalContext, "ptr") at the bottom of this function.

(Optionally just call the first function once when starting WindowPadX).

There are also other ways to solve this (see first link under refrences).

Refrences:

AHK Post describing this call

SetThreadDpiAwarenessContext documentation - from Microsoft Description of function argument (enum value) - from Microsoft

alapo commented 4 years ago

To make WPXA_Move size the windows correctly on monitors with different DPI than the main monitor, call: originalContext := DllCall("SetThreadDpiAwarenessContext", "ptr", -3, "ptr") at the top of WPXA_Move and DllCall("SetThreadDpiAwarenessContext", "ptr", originalContext, "ptr") at the bottom of this function.

(Optionally just call the first function once when starting WindowPadX).

There are also other ways to solve this (see first link under refrences).

Refrences:

AHK Post describing this call

SetThreadDpiAwarenessContext documentation - from Microsoft Description of function argument (enum value) - from Microsoft

Thanks for your answer @BjAlvestad just wanted to confirm that within WPXA.ahk I insert it before the if statements shown in figure below.

img

and your second slice of code on line 1216

img

I tried this and I still get issues as shown in the screenshots in my previous post. I did want to comment that if I press Win+Left (the default for half screen in Windows) then I do not have a gap in the windows. Both my monitors are 1920x1080p