pmb6tz / windows-desktop-switcher

An AutoHotKey script for Windows that lets a user change virtual desktops by pressing CapsLock + <num>.
MIT License
1.23k stars 229 forks source link

Current window not shifting to other virtual desktop #54

Open submeg opened 4 years ago

submeg commented 4 years ago

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 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

Elijas commented 4 years ago

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

submeg commented 4 years ago

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 commented 4 years ago

@Elijas @pmb6tz,

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

Elijas commented 4 years ago

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.

submeg commented 4 years ago

@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

ghost commented 4 years ago

I have the Same Issue, I am on windows 1909

ghost commented 4 years ago

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

submeg commented 4 years ago

hi all, any news on this one?

ngmariusz commented 3 years ago

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

MikeHotelOscar commented 3 years ago

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?

donhector commented 3 years ago

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

GrandTourism commented 3 years ago

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

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

fredless commented 3 years ago

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

PovilasAtPoq commented 2 years ago

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

submeg commented 2 weeks ago

Looks like this is still open; my current work around has been to have Windows + Tab on a hotkey, shift the program manually and then navigate to the desktop.