From fb4a44415ddd43e3e7479f45fb6b0b475fa35001 Mon Sep 17 00:00:00 2001 From: Linus Date: Sun, 28 Jan 2024 18:06:48 +0100 Subject: [PATCH 1/2] First fix https://github.com/FuPeiJiang/VD.ahk/compare/v2_port...mac-s-g:VD.ahk:v2_port --- VD.ah2 | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/VD.ah2 b/VD.ah2 index d90394e..41aa599 100644 --- a/VD.ah2 +++ b/VD.ah2 @@ -14,12 +14,12 @@ class VD { if (buildNumber < 22000) { IID_IVirtualDesktopManagerInternal_ := "{F31574D6-B682-4CDC-BD56-1827860ABEC6}" IID_IVirtualDesktop_ := "{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4}" - this._dll_GetCurrentDesktop := this._dll_GetCurrentDesktop_Win10 - this._dll_GetDesktops := this._dll_GetDesktops_Win10 - this._dll_CreateDesktop := this._dll_CreateDesktop_Win10 + this._dll_GetCurrentDesktop := this._dll_GetCurrentDesktop_Win_Default + this._dll_GetDesktops := this._dll_GetDesktops_Win_Default + this._dll_CreateDesktop := this._dll_CreateDesktop_Win_Default this._dll_GetName := this._dll_GetName_Win10 this.RegisterDesktopNotifications := this.RegisterDesktopNotifications_Win10 - } else { + } else if (buildNumber < 22621) { IID_IVirtualDesktopManagerInternal_ := "{B2F925B9-5A0F-4D2E-9F4D-2B1507593C10}" IID_IVirtualDesktop_ := "{536D3495-B208-4CC9-AE26-DE8111275BF8}" this._dll_GetCurrentDesktop := this._dll_GetCurrentDesktop_Win11 @@ -27,6 +27,15 @@ class VD { this._dll_CreateDesktop := this._dll_CreateDesktop_Win11 this._dll_GetName := this._dll_GetName_Win11 this.RegisterDesktopNotifications := this.RegisterDesktopNotifications_Win11 + } else { + ; Win11 after breaking changes made at build 22621.2215 + IID_IVirtualDesktopManagerInternal_ := "{A3175F2D-239C-4BD2-8AA0-EEBA8B0B138E}" + IID_IVirtualDesktop_ := "{3F07F4BE-B107-441A-AF0F-39D82529072C}" + this._dll_GetDesktops := this._dll_GetDesktops_Win_Default + this._dll_GetCurrentDesktop := this._dll_GetCurrentDesktop_Win_Default + this._dll_CreateDesktop := this._dll_CreateDesktop_Win_Default + this._dll_GetName := this._dll_GetName_Win11 + this.RegisterDesktopNotifications := this.RegisterDesktopNotifications_Win11 } this.IVirtualDesktopManager := ComObject("{AA509086-5CA9-4C25-8F95-589D3C07B48A}", "{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}") this.GetWindowDesktopId := this._vtable(this.IVirtualDesktopManager.Ptr, 4) @@ -46,11 +55,17 @@ class VD { this.Ptr_CreateDesktop := this._vtable(this.IVirtualDesktopManagerInternal.Ptr, 10) this.Ptr_RemoveDesktop := this._vtable(this.IVirtualDesktopManagerInternal.Ptr, 12) this.FindDesktop := this._vtable(this.IVirtualDesktopManagerInternal.Ptr, 13) - } else { + } else if (buildNumber < 22621) { this.GetDesktops := this._vtable(this.IVirtualDesktopManagerInternal.Ptr, 8) this.Ptr_CreateDesktop := this._vtable(this.IVirtualDesktopManagerInternal.Ptr, 11) this.Ptr_RemoveDesktop := this._vtable(this.IVirtualDesktopManagerInternal.Ptr, 13) this.FindDesktop := this._vtable(this.IVirtualDesktopManagerInternal.Ptr, 14) + } else { + ; Win11 after breaking changes made at build 22621.2215 + this.GetDesktops := this._vtable(this.IVirtualDesktopManagerInternal.Ptr, 7) + this.Ptr_CreateDesktop := this._vtable(this.IVirtualDesktopManagerInternal.Ptr, 10) + this.Ptr_RemoveDesktop := this._vtable(this.IVirtualDesktopManagerInternal.Ptr, 12) + this.FindDesktop := this._vtable(this.IVirtualDesktopManagerInternal.Ptr, 13) } this.IVirtualDesktopPinnedApps := ComObjQuery(this.IServiceProvider.Ptr, "{B5A399E7-1C87-46B8-88E9-FC5747B171BD}", "{4CE81583-1E4C-4632-A621-07A53543148F}") this.IsViewPinned := this._vtable(this.IVirtualDesktopPinnedApps.Ptr, 6) @@ -66,7 +81,7 @@ class VD { DllCall("Ole32.dll\CLSIDFromString", "Str", IID_IVirtualDesktop_, "Ptr", this.Ptr_IID_IVirtualDesktop) this.savedLocalizedWord_Desktop := false } - static _dll_GetCurrentDesktop_Win10() { + static _dll_GetCurrentDesktop_Win_Default() { IVirtualDesktop_ofCurrentDesktop := 0 DllCall(this.GetCurrentDesktop, "UPtr", this.IVirtualDesktopManagerInternal.Ptr, "Ptr*", &IVirtualDesktop_ofCurrentDesktop := 0) return IVirtualDesktop_ofCurrentDesktop @@ -76,7 +91,7 @@ class VD { DllCall(this.GetCurrentDesktop, "UPtr", this.IVirtualDesktopManagerInternal.Ptr, "Ptr", 0, "Ptr*", &IVirtualDesktop_ofCurrentDesktop := 0) return IVirtualDesktop_ofCurrentDesktop } - static _dll_GetDesktops_Win10() { + static _dll_GetDesktops_Win_Default() { IObjectArray := 0 DllCall(this.GetDesktops, "UPtr", this.IVirtualDesktopManagerInternal.Ptr, "Ptr*", &IObjectArray := 0) return IObjectArray @@ -86,7 +101,7 @@ class VD { DllCall(this.GetDesktops, "UPtr", this.IVirtualDesktopManagerInternal.Ptr, "Ptr", 0, "UPtr*", &IObjectArray := 0) return IObjectArray } - static _dll_CreateDesktop_Win10() { + static _dll_CreateDesktop_Win_Default() { IVirtualDesktop_ofNewDesktop := 0 DllCall(this.Ptr_CreateDesktop, "UPtr", this.IVirtualDesktopManagerInternal.Ptr, "Ptr*", &IVirtualDesktop_ofNewDesktop := 0) return IVirtualDesktop_ofNewDesktop -- 2.37.2.windows.2 From 469e6c2c19ce8da1f56df807dc7bc3105df3d2e1 Mon Sep 17 00:00:00 2001 From: Linus Date: Sun, 28 Jan 2024 18:34:00 +0100 Subject: [PATCH 2/2] Second fix https://github.com/FuPeiJiang/VD.ahk/commit/1d9a94ef8ef87a4fc6d2cb5f83b6d068302a03d9 --- VD.ah2 | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/VD.ah2 b/VD.ah2 index 41aa599..c6e10c0 100644 --- a/VD.ah2 +++ b/VD.ah2 @@ -27,7 +27,8 @@ class VD { this._dll_CreateDesktop := this._dll_CreateDesktop_Win11 this._dll_GetName := this._dll_GetName_Win11 this.RegisterDesktopNotifications := this.RegisterDesktopNotifications_Win11 - } else { + } else if (buildNumber < 22631) { + ; https://github.com/FuPeiJiang/VD.ahk/compare/v2_port...mac-s-g:VD.ahk:v2_port ; Win11 after breaking changes made at build 22621.2215 IID_IVirtualDesktopManagerInternal_ := "{A3175F2D-239C-4BD2-8AA0-EEBA8B0B138E}" IID_IVirtualDesktop_ := "{3F07F4BE-B107-441A-AF0F-39D82529072C}" @@ -36,6 +37,15 @@ class VD { this._dll_CreateDesktop := this._dll_CreateDesktop_Win_Default this._dll_GetName := this._dll_GetName_Win11 this.RegisterDesktopNotifications := this.RegisterDesktopNotifications_Win11 + } else { + ; https://github.com/FuPeiJiang/VD.ahk/commit/1d9a94ef8ef87a4fc6d2cb5f83b6d068302a03d9 + IID_IVirtualDesktopManagerInternal_ := "{4970BA3D-FD4E-4647-BEA3-D89076EF4B9C}" + IID_IVirtualDesktop_ := "{3F07F4BE-B107-441A-AF0F-39D82529072C}" + this._dll_GetDesktops := this._dll_GetDesktops_Win_Default + this._dll_GetCurrentDesktop := this._dll_GetCurrentDesktop_Win_Default + this._dll_CreateDesktop := this._dll_CreateDesktop_Win_Default + this._dll_GetName := this._dll_GetName_Win11 + this.RegisterDesktopNotifications := this.RegisterDesktopNotifications_Win11 } this.IVirtualDesktopManager := ComObject("{AA509086-5CA9-4C25-8F95-589D3C07B48A}", "{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}") this.GetWindowDesktopId := this._vtable(this.IVirtualDesktopManager.Ptr, 4) @@ -402,11 +412,18 @@ class VD { this.RegisterDesktopNotifications_Same(methods) } static _QueryInterface_Win11(riid, ppvObject) { + splitByDot := StrSplit(A_OSVersion, ".") + buildNumber := splitByDot[3] + if (!ppvObject) { return 0x80070057 } str_IID_IUnknown := "{00000000-0000-0000-C000-000000000046}" - str_IID_IVirtualDesktopNotification := "{CD403E52-DEED-4C13-B437-B98380F2B1E8}" + if (buildNumber < 22631) { + str_IID_IVirtualDesktopNotification := "{CD403E52-DEED-4C13-B437-B98380F2B1E8}" + } else { + str_IID_IVirtualDesktopNotification := "{B9E5E94D-233E-49AB-AF5C-2B4541C3AADE}" + } someStr := Buffer(40 * 2) DllCall("Ole32\StringFromGUID2", "Ptr", riid, "Ptr", someStr, "Ptr", 40) str_riid := StrGet(someStr) -- 2.37.2.windows.2