From 04226a26ed88865c60c60e9cd843c07d939479f9 Mon Sep 17 00:00:00 2001 From: mr-rak Date: Wed, 14 Sep 2016 23:48:52 +0300 Subject: [PATCH] Fix WinMove for Windows 10, fix defoult grid name. --- Command.ahk | 5 ++++- GridMove.ahk | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Command.ahk b/Command.ahk index ea98458..1d50eba 100644 --- a/Command.ahk +++ b/Command.ahk @@ -290,7 +290,10 @@ MoveToGrid(GridToMove) if ShouldUseSizeMoveMessage(WinClass) SendMessage WM_ENTERSIZEMOVE, , , ,ahk_id %windowid% - WinMove, A, ,%GridLeft%,%GridTop%,%GridWidth%,%GridHeight% + if Windows10 + WinSnap("ahk_id" windowid, GridLeft,GridTop, GridWidth, GridHeight) + else + WinMove, A, ,%GridLeft%,%GridTop%,%GridWidth%,%GridHeight% if ShouldUseSizeMoveMessage(WinClass) SendMessage WM_EXITSIZEMOVE, , , ,ahk_id %windowid% diff --git a/GridMove.ahk b/GridMove.ahk index 8c31fbb..21aec13 100644 --- a/GridMove.ahk +++ b/GridMove.ahk @@ -11,8 +11,8 @@ ShowGroupsFlag := True ;configures the showing or not of the groups ShowNumbersFlag := True ;configures the showing or not of the numbers TitleSize := 100 - GridName = Grids/3-part.grid - GridOrder = 2 Part-Vertical,3-Part,EdgeGrid,Dual-Screen + GridName = Grids/3 Part.grid + GridOrder = 2 Part Vertical,3 Part,EdgeGrid,Dual Screen UseCommand := True CommandHotkey = #g UseFastMove := True @@ -36,7 +36,31 @@ ;;end of options - ScriptVersion = 1.19.72 + ScriptVersion = 1.19.72-win10fix + + ; Detect Windows 10 + if % substr(a_osversion, 1, 2) = 10 + Windows10:=True + + ; Hack WinMove for Windows 10 + WinSnap(WinTitle, X := "", Y := "", W := "", H := "") { + If ((X . Y . W . H) = "") ; + Return False + WinGet, hWnd, ID, %WinTitle% ; taken from Coco's version + If !(hWnd) + Return False + DL := DT := DR := DB := 0 + VarSetCapacity(RC, 16, 0) + DllCall("GetWindowRect", "Ptr", hWnd, "Ptr", &RC) + WL := NumGet(RC, 0, "Int"), WT := NumGet(RC, 4, "Int"), WR := NumGet(RC, 8, "Int"), WB := NumGet(RC, 12, "Int") + If (DllCall("Dwmapi.dll\DwmGetWindowAttribute", "Ptr", hWnd, "UInt", 9, "Ptr", &RC, "UInt", 16) = 0) { ; S_OK = 0 + FL := NumGet(RC, 0, "Int"), FT := NumGet(RC, 4, "Int"), FR := NumGet(RC, 8, "Int"), FB := NumGet(RC, 12, "Int") + DL := WL - FL, DT := WT - FT, DR := WR - FR, DB := WB - FB + } + X := X <> "" ? X + DL : WL, Y := Y <> "" ? Y + DT : WT + W := W <> "" ? W - DL + DR : WR - WL, H := H <> "" ? H - DT + DB: WB - WT + Return DllCall("MoveWindow", "Ptr", hWnd, "Int", X, "Int", Y, "Int", W, "Int", H, "UInt", 1) + } MutexExists("GridMove_XB032") @@ -651,7 +675,10 @@ SnapWindow: if ShouldUseSizeMoveMessage(WinClass) SendMessage WM_ENTERSIZEMOVE, , , ,ahk_id %windowid% - WinMove, ahk_id %windowid%, ,%GridLeft%,%GridTop%,%GridWidth%,%GridHeight%, + if Windows10 + WinSnap("ahk_id" windowid, GridLeft,GridTop, GridWidth, GridHeight) + else + WinMove, ahk_id %windowid%, ,%GridLeft%,%GridTop%,%GridWidth%,%GridHeight%, if ShouldUseSizeMoveMessage(WinClass) SendMessage WM_EXITSIZEMOVE, , , ,ahk_id %windowid%