aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2020-10-23 01:27:11 +0200
committerJohn Ankarström <john@ankarstrom.se>2020-10-23 01:27:11 +0200
commitaff6b7d7c99f8b99d0da630fb97d8576043a916a (patch)
tree5a49278f562c6a02ecdeecb8e00d6de7274bbe12
parent0a04ca2cd728982cd3a47cefad9d3101b455c6d6 (diff)
downloaddrm-aff6b7d7c99f8b99d0da630fb97d8576043a916a.tar.gz
release 1.4
-rw-r--r--CHANGELOG.txt11
-rw-r--r--drm.ahk55
-rw-r--r--drm.exebin836608 -> 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
--- a/drm.exe
+++ b/drm.exe
Binary files differ