jpginc/windows10DesktopManager

Detect Virtual Desktop location of a given WinTitle

Closed this issue · 1 comments

Hello, first of all, thanks for your script. I would like to ask if it could be possible with your library to detect the index of the Virtual Desktop hosting a certain window identified through WinTitle (for example, by providing its ahk_id, or ahk_exe, etc.).

Thank you

There isn't an function setup to do it but you can utilise the VirtualDeskopManagerClass and DesktopMapperClass to do it. Here is an example

hwnd := WinExist("ahk_exe notepad.exe")
vDManager := new VirtualDesktopManagerClass()
virtualDesktopGuid := vDManager.getDesktopGuid(hwnd)
dManager := new DesktopMapperClass("ignore this")
dManager.mapVirtualDesktops()
virtualDesktopId := dManager._idFromGuid(virtualDesktopGuid)
virtualDesktopNumber := dManager._indexOfId(virtualDesktopId)
msgbox % "hwnd: " hwnd "`ndesktop guid: " virtualDesktopGuid "`ndesktop id: " virtualDesktopId "`ndesktop number: " virtualDesktopNumber