MScholtes / VirtualDesktop

C# command line tool to manage virtual desktops in Windows 10
MIT License
606 stars 60 forks source link

Moving window by handle fails but move by PID works fine #13

Closed lenwhite closed 4 years ago

lenwhite commented 4 years ago

Encountered this issue when attempting to move a window of this program: https://github.com/transmission-remote-gui/transgui

Invoking the executable as .\VirtualDesktop Verbose GetDesktop:0 mw:<PID> works fine, but invoking it as .\VirtualDesktop Verbose GetDesktop:0 maw (after a delay and switching to the same window) results in an error:

Verbose mode enabled
Virtual desktop 0 selected
Moving active window to virtual desktop 0
No active window or move failed

The exception given was:

Exception: System.Runtime.InteropServices.COMException (0x8007139F): The group or resource is not in the correct state to perform the requested operation. (Exception from HRESULT: 0x8007139F)
   at VirtualDesktop.IVirtualDesktopManagerInternal.MoveViewToDesktop(IApplicationView view, IVirtualDesktop desktop)
   at VirtualDesktop.Desktop.MoveWindow(IntPtr hWnd)
   at VDeskTool.Program.Main(String[] args)

Edit: same issue occurs when trying .\VirtualDesktop GetDesktop:0 mwh:<handle>

MScholtes commented 4 years ago

Hello lenwhite,

modified the project to address your issue. If a window is "not movable", the main window is used to move. Seems to work.

Made some advancements of meta data and icon too.

Greetings

Markus

lenwhite commented 4 years ago

Hi @MScholtes

That seems to have done the trick.

Cheers mate.