windows-desktop-switcher
windows-desktop-switcher copied to clipboard
function MoveCurrentWindowToDesktop() not working after windows 11 update
After updating windows 10 to 11 (built 22000.51) this function is no longer working. Compiling with autohotkey -v 1.1.39 unicode 64 bit. any suggestions how to make it work again? Thank you very much!
Yup. I discovered this problem today as well
Encountered the same problem in win11.
Is there any solution?
Does it get fixed with https://github.com/pmb6tz/windows-desktop-switcher/pull/76 ?
(Just download the newest version of the script, or manually apply the changes from the fix in the link)
Updated the latest code, but it still doesn't work, the window does not move, the following is the autohotkey execution log:
031: MoveCurrentWindowToDesktop(1)
---- D:\software\hotkey\热键绑定AutoHotkey.ahk
198: WinGet,activeHwnd,ID,A
199: DllCall(MoveWindowToDesktopNumberProc, UInt, activeHwnd, UInt, desktopNumber - 1)
200: switchDesktopByNumber(desktopNumber)
144: updateGlobalVariables()
138: mapDesktopsFromRegistry()
036: IdLength := 32
037: SessionId := getSessionId()
083: ProcessId := DllCall("GetCurrentProcessId", "UInt")
084: if ErrorLevel
088: OutputDebug,Current Process Id: %ProcessId%
090: DllCall("ProcessIdToSessionId", "UInt", ProcessId, "UInt*", SessionId)
091: if ErrorLevel
095: OutputDebug,Current Session Id: %SessionId%
096: Return,SessionId
038: if (SessionId)
039: RegRead,CurrentDesktopId,HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VirtualDesktops,CurrentVirtualDesktop
040: if ErrorLevel
044: if (CurrentDesktopId)
045: IdLength := StrLen(CurrentDesktopId)
046: }
047: }
050: RegRead,DesktopList,HKEY_CURRENT_USER,SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VirtualDesktops,VirtualDesktopIDs
051: if (DesktopList)
052: DesktopListLength := StrLen(DesktopList)
054: DesktopCount := floor(DesktopListLength / IdLength)
055: }
061: i := 0
062: While,(CurrentDesktopId && i < DesktopCount)
063: StartPos := (i * IdLength) + 1
064: DesktopIter := SubStr(DesktopList, StartPos, IdLength)
065: OutputDebug,The iterator is pointing at %DesktopIter% and count is %i%.
069: if (DesktopIter = CurrentDesktopId)
074: i += 1
075: }
062: While,(CurrentDesktopId && i < DesktopCount)
063: StartPos := (i * IdLength) + 1
064: DesktopIter := SubStr(DesktopList, StartPos, IdLength)
065: OutputDebug,The iterator is pointing at %DesktopIter% and count is %i%.
069: if (DesktopIter = CurrentDesktopId)
070: CurrentDesktop := i + 1
071: OutputDebug,Current desktop number is %CurrentDesktop% with an ID of %DesktopIter%.
072: Break
076: }
139: }
145: _switchDesktopToTarget(targetDesktop)
105: if (targetDesktop > DesktopCount || targetDesktop < 1 || targetDesktop == CurrentDesktop)
110: LastOpenedDesktop := CurrentDesktop
113: WinActivate,ahk_class Shell_TrayWnd (0.16)
116: While,(CurrentDesktop < targetDesktop)
123: While,(CurrentDesktop > targetDesktop)
124: Send,{LWin down}{LCtrl down}{Left down}{Lwin up}{LCtrl up}{Left up} (0.06)
125: CurrentDesktop -= 1
126: OutputDebug,[left] target: %targetDesktop% current: %CurrentDesktop%
127: }
123: While,(CurrentDesktop > targetDesktop)
130: Sleep,50 (0.05)
131: focusTheForemostWindow(targetDesktop)
170: foremostWindowId := getForemostWindowIdOnDesktop(targetDesktop)
183: n := n - 1
186: WinGet,winIDList,list
187: Loop,winIDList
188: windowID := winIDList%A_Index%
189: windowIsOnDesktop := DllCall(IsWindowOnDesktopNumberProc, UInt, windowID, UInt, n)
191: if (windowIsOnDesktop == 1)
194: }
188: windowID := winIDList%A_Index%
189: windowIsOnDesktop := DllCall(IsWindowOnDesktopNumberProc, UInt, windowID, UInt, n)
191: if (windowIsOnDesktop == 1)
194: }
188: windowID := winIDList%A_Index%
189: windowIsOnDesktop := DllCall(IsWindowOnDesktopNumberProc, UInt, windowID, UInt, n)
191: if (windowIsOnDesktop == 1)
194: }
188: windowID := winIDList%A_Index%
189: windowIsOnDesktop := DllCall(IsWindowOnDesktopNumberProc, UInt, windowID, UInt, n)
191: if (windowIsOnDesktop == 1)
194: }
188: windowID := winIDList%A_Index%
189: windowIsOnDesktop := DllCall(IsWindowOnDesktopNumberProc, UInt, windowID, UInt, n)
191: if (windowIsOnDesktop == 1)
194: }
188: windowID := winIDList%A_Index%
189: windowIsOnDesktop := DllCall(IsWindowOnDesktopNumberProc, UInt, windowID, UInt, n)
191: if (windowIsOnDesktop == 1)
194: }
188: windowID := winIDList%A_Index%
189: windowIsOnDesktop := DllCall(IsWindowOnDesktopNumberProc, UInt, windowID, UInt, n)
191: if (windowIsOnDesktop == 1)
194: }
188: windowID := winIDList%A_Index%
189: windowIsOnDesktop := DllCall(IsWindowOnDesktopNumberProc, UInt, windowID, UInt, n)
191: if (windowIsOnDesktop == 1)
194: }
188: windowID := winIDList%A_Index%
189: windowIsOnDesktop := DllCall(IsWindowOnDesktopNumberProc, UInt, windowID, UInt, n)
191: if (windowIsOnDesktop == 1)
194: }
188: windowID := winIDList%A_Index%
189: windowIsOnDesktop := DllCall(IsWindowOnDesktopNumberProc, UInt, windowID, UInt, n)
191: if (windowIsOnDesktop == 1)
194: }
188: windowID := winIDList%A_Index%
189: windowIsOnDesktop := DllCall(IsWindowOnDesktopNumberProc, UInt, windowID, UInt, n)
191: if (windowIsOnDesktop == 1)
194: }
195: }
171: if isWindowNonMinimized(foremostWindowId)
177: WinGet,MMX,MinMax,ahk_id %windowId%
178: Return,MMX != -1
172: WinActivate,ahk_id %foremostWindowId%
173: }
174: }
132: }
146: }
201: }
---- D:\software\hotkey\user_config.ahk
031: Return (6.70)
DIICall does not work with win11
MoveCurrentWindowToDesktop(desktopNumber) {
WinGet, activeHwnd, ID, A
DllCall(MoveWindowToDesktopNumberProc, UInt, activeHwnd, UInt, desktopNumber - 1)
switchDesktopByNumber(desktopNumber)
}
Instead VirtualDesktopAccessor.dll by https://github.com/skottmckay/VirtualDesktopAccessor/tree/master/x64/Release It works for me.
DIICall does not work with win11
MoveCurrentWindowToDesktop(desktopNumber) { WinGet, activeHwnd, ID, A DllCall(MoveWindowToDesktopNumberProc, UInt, activeHwnd, UInt, desktopNumber - 1) switchDesktopByNumber(desktopNumber) }
Instead VirtualDesktopAccessor.dll by https://github.com/skottmckay/VirtualDesktopAccessor/tree/master/x64/Release It works for me.
Not for me: trying to move a windows to a desktop AutoHotkey switch to that desktop but selected windows does not move
DIICall does not work with win11 MoveCurrentWindowToDesktop(desktopNumber) { WinGet, activeHwnd, ID, A DllCall(MoveWindowToDesktopNumberProc, UInt, activeHwnd, UInt, desktopNumber - 1) switchDesktopByNumber(desktopNumber) } Instead VirtualDesktopAccessor.dll by https://github.com/skottmckay/VirtualDesktopAccessor/tree/master/x64/Release It works for me.
Not for me: trying to move a windows to a desktop AutoHotkey switch to that desktop but selected windows does not move
Just now , maybe due to the windows update,the script not work again. But I found the DLL has updated three days ago. maybe it is a fix ,it works for me . suggestion take a try