windows-desktop-switcher icon indicating copy to clipboard operation
windows-desktop-switcher copied to clipboard

Current window not shifting to other virtual desktop

Open submeg opened this issue 4 years ago • 15 comments

Hi @pmb6tz

This is such a useful script, thank you for building it! I've been working remotely now for a few weeks and this script has been a saviour when only having one screen.

I'm trying to get the MoveCurrentWindowToDesktop(desktopNumber) to work, but haven't had any success.

  • The WinGet, activeHwnd, ID, A command works and pulls the right ID
  • The switchDesktopByNumber(desktopNumber) works and sends me to the right desktop

The program stays on the original desktop. So the issue must be this line:

DllCall(MoveWindowToDesktopNumberProc, UInt, activeHwnd, UInt, desktopNumber - 1)

Which looks at:

global MoveWindowToDesktopNumberProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "MoveWindowToDesktopNumber", "Ptr")

I haven't done any dll call stuff yet, so unsure where the issue may lay or if I missing something. Please let me know what I should look at to get this working. Thanks.

Regards,

submeg

submeg avatar Apr 29 '20 20:04 submeg

Hi, @submeg, We're glad you liked the script!

Could you share the windows versiom that you're on (e.g. Version 1903)? The DLL sometimes gets outdated with a new version

By the way, AFAIR, there is a shortcut in windows to move window to the next desktop - if it happens rapidly and robustly enough we could maybe just remove the use of the dll

Elijas avatar Apr 29 '20 21:04 Elijas

Hi @Elijas,

The Windows version I have is 1909.

Oh, if that's the case, I could update my script to trigger that shortcut? Does it know which desktop you want to move it to, or just the next available desktop (which I'm assuming wraps around)?

submeg avatar Apr 29 '20 21:04 submeg

@Elijas @pmb6tz,

I had a look, there's no native keyboard shortcut for this.

submeg avatar May 01 '20 11:05 submeg

Good news, I checked, the DLL still works with the version 1909.

Could you try to install VS 2017 runtimes vc_redist.x64.exe (and/or) vc_redist.x86.exe ? Because the DLLs repository lists it as a dependency and says it was not provided by Windows out-of-the-box at the time.

Elijas avatar May 01 '20 13:05 Elijas

@Elijas,

I installed both versions, but it will still just shift to the selected desktop, but will leave the active window on the previous desktop.

submeg

submeg avatar May 10 '20 21:05 submeg

I have the Same Issue, I am on windows 1909

ghost avatar May 29 '20 08:05 ghost

Test on another pc with windows 2004 Update, Desktop switching working well but Can't move Active windows to another desktop

ghost avatar May 29 '20 14:05 ghost

hi all, any news on this one?

submeg avatar Jul 05 '20 00:07 submeg

i have 20231, 1005 (windows pro insider preview) and same issue; how can i fix it?

ngmariusz avatar Nov 12 '20 17:11 ngmariusz

I had this same issue, it was fixed by making sure that the line global hVirtualDesktopAccessor := DllCall("LoadLibrary", "Str", A_ScriptDir . "\VirtualDesktopAccessor.dll", "Ptr") pointed accurately at VirtualDesktopAccessor.dll. Is the dll file in the same folder as the script calling the fuctions?

MikeHotelOscar avatar Dec 22 '20 23:12 MikeHotelOscar

No luck here either. Windows 10 20H2, build number 19042.746

donhector avatar Jan 27 '21 16:01 donhector

Здесь тоже не повезло. Windows 10 20H2, номер сборки19042.746

I have the exact same build and it works great on a lot of machines

GrandTourism avatar Jan 27 '21 17:01 GrandTourism

pointed accurately at VirtualDesktopAccessor.dll

initially had this issue too, but as @MikeHotelOscar pointed out, the problem was making sure the script could find the DLL

on ver 20H2 build 19042.662

fredless avatar Feb 18 '21 02:02 fredless

pointed accurately at VirtualDesktopAccessor.dll

initially had this issue too, but as @MikeHotelOscar pointed out, the problem was making sure the script could find the DLL

on ver 20H2 build 19042.662

And how does one fixes that? I tried putting full path to the desktop_switcher.ahk, but that doesn't help. Tried removing the first \ doesn't help either.

P.S. I'm using win11

PovilasAtPoq avatar Jul 26 '22 17:07 PovilasAtPoq