aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2020-10-23 01:25:30 +0200
committerJohn Ankarström <john@ankarstrom.se>2020-10-23 01:25:30 +0200
commit0a04ca2cd728982cd3a47cefad9d3101b455c6d6 (patch)
tree7158aa009a30469ee765c3a24c0117d81b120535
parenta2e0cf3af7b7b2af24f157c3092a382e8fddec15 (diff)
downloaddrm-0a04ca2cd728982cd3a47cefad9d3101b455c6d6.tar.gz
release 1.3.2
-rw-r--r--CHANGELOG.txt10
-rw-r--r--drm.ahk117
2 files changed, 88 insertions, 39 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index a82aff2..7b9c141 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,4 +1,8 @@
-CHANGELOG ---------------------- 1.3.1 --------------------- 2020-04-29
+CHANGELOG ---------------------- 1.3.2 --------------------- 2020-05-02
-FIX: Now calculates correctly whether windows with IgnoreSize should be
- aligned to the right side or bottom of the screen. \ No newline at end of file
+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
diff --git a/drm.ahk b/drm.ahk
index 90c2d3f..11dd793 100644
--- a/drm.ahk
+++ b/drm.ahk
@@ -41,6 +41,7 @@ if (ErrorLevel = 1)
; Set up tray menu
Menu, Tray, NoStandard
+Menu, Tray, Icon, % "HBITMAP:*" . Create_tray_ico()
Menu, Tray, Tip, Dynamic Resolution Manager
for k, res in Resolutions
Menu, Tray, Add, %res%, SelectMenuResolution
@@ -98,76 +99,85 @@ Save(ByRef Positions)
Positions := {}
WinGet, id, list
SysGet, WorkArea, MonitorWorkArea
- Width := WorkAreaRight - WorkAreaLeft
- Height := WorkAreaBottom - WorkAreaTop
+ wa := { w: WorkAreaRight - WorkAreaLeft, h: WorkAreaBottom - WorkAreaTop }
Loop, %id%
{
+ DoIgnore := DoIgnoreSize := false
+ p := {}
i := id%A_Index%
WinReallyGetPos(i, x, y, w, h)
+ SysGet, bx, 32 ; window border thickness (x)
+ SysGet, by, 33 ; window border thickness (y)
+ cw := w - bx * 2 ; client width
+ ch := h - by * 2 ; client height
WinGet, exe, ProcessName, ahk_id %i%
+ ; Custom rules
+
+ ; Example:
+ ; if (exe = "mpc-hc.exe" and cw = 294)
+ ; DoIgnoreSize := true
+
; Ignore position and size (2)
- if (InStr(IgnoreString, "|" exe))
- Positions[i] := [x, y, w, h, 2, 0]
+ if (DoIgnore or InStr(IgnoreString, "|" exe))
+ p := {x: x, y: y, w: w, h: h, ignore: 2, align: 0}
; Ignore size, but retain position (1)
- else if (InStr(IgnoreSizeString, "|" exe))
+ else if (DoIgnoreSize or InStr(IgnoreSizeString, "|" exe))
{
- rx := x / Width
- ry := y / Height
+ p.ignore := 1
+ p.w := w
+ p.h := h
+ p.x := x / wa.w
+ p.y := y / wa.h
- ; Calculate position relative to right/bottom if necessary
+ ; Re-calculate position relative to right/bottom if necessary
- Align := 1 ; to align right, this should be divisible by 3; bottom, by 5
- if (x > Width - (x + w))
+ p.align := 1 ; to align right, this should be divisible by 3; bottom, by 5
+ if (x > wa.w - (x + w))
{
- Align := Align * 3
- rx := (Width - (x + w)) / Width
+ p.align := p.align * 3
+ p.x := (wa.w - (x + w)) / wa.w
}
- if (y > Height - (y + h))
+ if (y > wa.h - (y + h))
{
- Align := Align * 5
- ry := (Height - (y + h)) / Height
+ p.align := p.align * 5
+ p.y := (wa.h - (y + h)) / wa.h
}
-
- Positions[i] := [rx, ry, w, h, 1, Align]
}
; Retain position and size (0)
else
- Positions[i] := [x / Width, y / Height, w / Width, h / Height, 0, 0]
+ p := {x: x / wa.w, y: y / wa.h, w: w / wa.w, h: h / wa.h, ignore: 0, align: 0}
+
+ Positions[i] := p
}
}
Restore(Positions)
{
SysGet, WorkArea, MonitorWorkArea
- Width := WorkAreaRight - WorkAreaLeft
- Height := WorkAreaBottom - WorkAreaTop
- for i, props in Positions
+ wa := { w: WorkAreaRight - WorkAreaLeft, h: WorkAreaBottom - WorkAreaTop }
+ for i, p in Positions
{
- x := props[1]
- y := props[2]
- w := props[3]
- h := props[4]
- if (props[5] = 2) ; ignore position and size
- WinReallyMove(i, x, y, w, h)
- else if (props[5] = 1) ; ignore size, but retain position
+ if (p.ignore = 2) ; ignore position and size
+ WinReallyMove(i, p.x, p.y, p.w, p.h)
+ else if (p.ignore = 1) ; ignore size, but retain position
{
- rx := x * Width
- ry := y * Height
- if (Mod(props[6], 3) = 0) ; align right
- rx := Width - rx - w
- if (Mod(props[6], 5) = 0) ; align bottom
- ry := Height - ry - h
- WinReallyMove(i, rx, ry, w, h)
+ x := p.x * wa.w
+ y := p.y * wa.h
+ if (Mod(p.align, 3) = 0) ; align right
+ x := wa.w - x - p.w
+ if (Mod(p.align, 5) = 0) ; align bottom
+ y := wa.h - y - p.h
+ WinReallyMove(i, x, y, p.w, p.h)
}
else ; retain position and size
- WinReallyMove(i, x * Width, y * Height, w * Width, h * Height)
+ WinReallyMove(i, p.x * wa.w, p.y * wa.h, p.w * wa.w, p.h * wa.h)
}
}
@@ -208,4 +218,39 @@ WinReallyMove(hwnd, x, y, w, h)
NumPut(w + x, wp, 36, "int")
NumPut(h + y, wp, 40, "int")
DllCall("SetWindowPlacement", "ptr", hwnd, "ptr", &wp)
+}
+
+; ##################################################################################
+; # This #Include file was generated by Image2Include.ahk, you must not change it! #
+; ##################################################################################
+Create_tray_ico(NewHandle := False) {
+Static hBitmap := 0
+If (NewHandle)
+ hBitmap := 0
+If (hBitmap)
+ Return hBitmap
+VarSetCapacity(B64, 2984 << !!A_IsUnicode)
+B64 := "AAABAAEAICAAAAAAAACoCAAAFgAAACgAAAAgAAAAQAAAAAEACAAAAAAAgAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAMDcwADwyqYABAQ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uL//fsAOz/vPcAi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4v/9+wA7P+89wCL//+Li4uLi4uLi4uLi4uLi4uLi4uLi//37ADs/7z3AIv/+4uLi4uLi4uLi4uLi4uLi4uLi4uL//fsAOz/vPcAi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4v/9+wA7P+89wCL//6Li4uLi4uLi4uLi4uLi4uLi4uLi//37ADs/7z3AIv++4uLi4uLi4uLi4uLi4uLi4uLi4uL//fsAOz/vPcAi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4v/9+wA7P+89wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/37ADs/7z39/f39/f39/f39/f39/f39/f39/f39/f39/fsAOz/vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vOwA7P//////////////////////////////////////vADs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OzsAP+AAf//gAH//4AB/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+If !DllCall("Crypt32.dll\CryptStringToBinary", "Ptr", &B64, "UInt", 0, "UInt", 0x01, "Ptr", 0, "UIntP", DecLen, "Ptr", 0, "Ptr", 0)
+ Return False
+VarSetCapacity(Dec, DecLen, 0)
+If !DllCall("Crypt32.dll\CryptStringToBinary", "Ptr", &B64, "UInt", 0, "UInt", 0x01, "Ptr", &Dec, "UIntP", DecLen, "Ptr", 0, "Ptr", 0)
+ Return False
+; Bitmap creation adopted from "How to convert Image data (JPEG/PNG/GIF) to hBITMAP?" by SKAN
+; -> http://www.autohotkey.com/board/topic/21213-how-to-convert-image-data-jpegpnggif-to-hbitmap/?p=139257
+hData := DllCall("Kernel32.dll\GlobalAlloc", "UInt", 2, "UPtr", DecLen, "UPtr")
+pData := DllCall("Kernel32.dll\GlobalLock", "Ptr", hData, "UPtr")
+DllCall("Kernel32.dll\RtlMoveMemory", "Ptr", pData, "Ptr", &Dec, "UPtr", DecLen)
+DllCall("Kernel32.dll\GlobalUnlock", "Ptr", hData)
+DllCall("Ole32.dll\CreateStreamOnHGlobal", "Ptr", hData, "Int", True, "PtrP", pStream)
+hGdip := DllCall("Kernel32.dll\LoadLibrary", "Str", "Gdiplus.dll", "UPtr")
+VarSetCapacity(SI, 16, 0), NumPut(1, SI, 0, "UChar")
+DllCall("Gdiplus.dll\GdiplusStartup", "PtrP", pToken, "Ptr", &SI, "Ptr", 0)
+DllCall("Gdiplus.dll\GdipCreateBitmapFromStream", "Ptr", pStream, "PtrP", pBitmap)
+DllCall("Gdiplus.dll\GdipCreateHBITMAPFromBitmap", "Ptr", pBitmap, "PtrP", hBitmap, "UInt", 0)
+DllCall("Gdiplus.dll\GdipDisposeImage", "Ptr", pBitmap)
+DllCall("Gdiplus.dll\GdiplusShutdown", "Ptr", pToken)
+DllCall("Kernel32.dll\FreeLibrary", "Ptr", hGdip)
+DllCall(NumGet(NumGet(pStream + 0, 0, "UPtr") + (A_PtrSize * 2), 0, "UPtr"), "Ptr", pStream)
+Return hBitmap
} \ No newline at end of file