Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Win-10 Virtual Desktop / Can QM determine this
#1
Hello to All!
Can QM's determine the virtual desktop that is active?

FOR INSTANCE: 
Let's say you have 9 virtual desktops and you are on #5
Does QM's have the ability to determine this?

Thanks!!!
#2
Microsoft offers only 2 working functions for virtual desktops:
IVirtualDesktopManager.GetWindowDesktopId - gets desktop GUID. It is useful only to compare with desktop GUID of another window.
IVirtualDesktopManager.IsWindowOnCurrentVirtualDesktop.
Also there is IVirtualDesktopManager. MoveWindowToDesktop but does not work with windows of other processes.
And these two are unreliable. They work not with all windows. Need to test and know everything.

Macro IVirtualDesktopManager
Code:
Copy      Help
interface# IVirtualDesktopManager :IUnknown
,#IsWindowOnCurrentVirtualDesktop(topLevelWindow)
,GUID'GetWindowDesktopId(topLevelWindow)
,MoveWindowToDesktop(topLevelWindow GUID&desktopId)
,{a5cd92ff-29be-454c-8d04-d82879fb3f1b}

interface IVirtualDesktopManager_Raw :IUnknown
,#IsWindowOnCurrentVirtualDesktop(topLevelWindow &is)
,#GetWindowDesktopId(topLevelWindow GUID&desktopId)
,#MoveWindowToDesktop(topLevelWindow GUID&desktopId)
,{a5cd92ff-29be-454c-8d04-d82879fb3f1b}

Function __GetVirtualDesktopManager
Code:
Copy      Help
function! IVirtualDesktopManager_Raw&m

IVirtualDesktopManager_Raw- __t_vdeskman._create("{aa509086-5ca9-4c25-8f95-589d3c07b48a}"); err
m=__t_vdeskman
ret m!=0

Function IsWindowOnCurrentDesktop
Code:
Copy      Help
;/
function! hwnd

;Returns 1 if the window is on the currently active virtual desktop, 2 if on all desktops. Returns 0 if it is on an inactive desktop.

;REMARKS
;Virtual desktops is a Windows 10 feature. On older OS this function always returns 1.

;
if(_winver<0xA00) ret 2

#compile "IVirtualDesktopManager"

if(!IsWindow(hwnd)) ret
if(!IsWindowCloaked(hwnd)) ret 1 ;;much faster

int ho=GetAncestor(hwnd 3); if(!ho) ret ;;would fail if owned window. Tested: an owned window cannot be on a different desktop than its owner.
if ho!=hwnd
,int hp=GetAncestor(ho 2)
,if(hp!=ho) ho=GetAncestor(hp 3); if(!ho) ret ;;QM toolbar owners used to be child windows with ws_popup style, and GetAncestor(hwnd 3) does not get their owner. Tested: GA gets root owner if direct owner is normal child window (ws_child).
,hwnd=ho
;tested: GA returns hwnd if hwnd is owned by desktop, except if it has ws_child style, eg ComboLBox.

;IVirtualDesktopManager_Raw-- m._create("{aa509086-5ca9-4c25-8f95-589d3c07b48a}")
;IVirtualDesktopManager_Raw- t_vdeskman._create("{aa509086-5ca9-4c25-8f95-589d3c07b48a}")
IVirtualDesktopManager_Raw m; if(!__GetVirtualDesktopManager(m)) ret

int R
if(m.IsWindowOnCurrentVirtualDesktop(hwnd R)) ret 2 ;;if fails, the window does not have a desktop assigned, then assume that it is on all desktops
ret R

;TODO: test how when the desktop switcher is active.


Forum Jump:


Users browsing this thread: 1 Guest(s)