From aff6b7d7c99f8b99d0da630fb97d8576043a916a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Fri, 23 Oct 2020 01:27:11 +0200 Subject: release 1.4 --- CHANGELOG.txt | 11 ++++------- drm.ahk | 55 ++++++++++++++++++++++++++++++++++++++++++++----------- drm.exe | Bin 836608 -> 836608 bytes 3 files changed, 48 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 7b9c141..3c7f2d2 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,8 +1,5 @@ -CHANGELOG ---------------------- 1.3.2 --------------------- 2020-05-02 +CHANGELOG ----------------------- 1.4 ---------------------- 2020-05-03 -NEW: Tray icon is now included again for non-compiled version too. -NEW: Designated place for custom rules (line 117), where users can - easily control the window handling for certain windows via the - variables DoIgnore and DoIgnoreSize. Example included on line 119. -ETC: The window handling code is now cleaner and a bit more - self-explanatory. \ No newline at end of file +NEW: Support for custom refresh rates in the Resolutions registry key, + e.g. "1600x1200 72Hz|1280x960 80Hz|1024x768 110Hz". Note that this + exact syntax must be used. \ No newline at end of file diff --git a/drm.ahk b/drm.ahk index 11dd793..c373b2c 100644 --- a/drm.ahk +++ b/drm.ahk @@ -65,18 +65,35 @@ Configure() SelectMenuResolution(ItemName, ItemPos, MenuName) { - ResArray := StrSplit(ItemName, "x") - SwitchToResolutionFrom(ResArray[1], ResArray[2], A_ScreenWidth, A_ScreenHeight) + w := 0 + h := 0 + r := 0 + for k, v in StrSplit(ItemName, " ") + { + if (k = 1) + { + a := StrSplit(v, "x") + w := a[1] + h := a[2] + } + else if ("Hz" = SubStr(v, StrLen(v) - 1)) + r := SubStr(v, 1, StrLen(v) - 2) + } + if (w = 0 or h = 0) + MsgBox, Invalid width or height + new := {width: w, height: h, rate: r, depth: 32} + old := Get() + SwitchResolution(new, old) } ; Save window positions, switch to given resolution, restore window positions -SwitchToResolutionFrom(WidthNew, HeightNew, WidthOrig, HeightOrig) +SwitchResolution(new, old) { Positions := {} Save(Positions) - SetResolution(WidthNew, HeightNew) + Set(new) Sleep, 500 Restore(Positions) @@ -86,7 +103,7 @@ SwitchToResolutionFrom(WidthNew, HeightNew, WidthOrig, HeightOrig) if (ErrorLevel = 1) ; user didn't press escape return - SetResolution(%WidthOrig%, %HeightOrig%) + Set(old) Sleep, 500 Restore(Positions) } @@ -183,18 +200,34 @@ Restore(Positions) ; Set screen resolution -SetResolution(Width, Height, ColorDepth := 32) +Set(res) { VarSetCapacity(DeviceMode, 156, 0) - NumPut(156, DeviceMode, 36) + NumPut(156, DeviceMode, 36) DllCall("EnumDisplaySettingsA", UInt, 0, UInt, -1, UInt, &DeviceMode) - NumPut(0x5c0000, DeviceMode, 40) - NumPut(ColorDepth, DeviceMode, 104) - NumPut(Width, DeviceMode, 108) - NumPut(Height, DeviceMode, 112) + NumPut(0x5c0000, DeviceMode, 40) + NumPut(res.depth, DeviceMode, 104) + NumPut(res.width, DeviceMode, 108) + NumPut(res.height, DeviceMode, 112) + if (res.rate > 0) + NumPut(res.rate, DeviceMode, 120) DllCall("ChangeDisplaySettingsA", UInt, &DeviceMode, UInt, 0) } +; Get screen resolution + +Get() +{ + VarSetCapacity(DeviceMode, 156, 0) + NumPut(156, DeviceMode, 36) + DllCall("EnumDisplaySettingsA", UInt, 0, UInt, -1, UInt, &DeviceMode) + w := NumGet(&DeviceMode, 108, "uint4") + h := NumGet(&DeviceMode, 112, "uint4") + d := NumGet(&DeviceMode, 104, "uint4") + r := NumGet(&DeviceMode, 120, "uint4") + return {width: w, height: h, depth: d, rate: r} +} + ; Get position of any window, even a minimized one WinReallyGetPos(hwnd, ByRef x, ByRef y, ByRef w="", ByRef h="") diff --git a/drm.exe b/drm.exe index 7fecea2..c7edd11 100644 Binary files a/drm.exe and b/drm.exe differ -- cgit v1.2.3