Autohotkey Windows 10 Virtual Desktops

1.5k Views Asked by At

I have an AHK script which saves window positions. At the moment I save Title, X, Y, Width, Height, Class, FullPath etc. I also want to save on which Virtual Desktop they are located on.

I dont know how Windows 10 handles Virtual Desktops: Do they have a UID? Do these UIDs change after a reboot? Is there any way to actually number them?

I would like to do it in a way which has a low chance of breaking in case of a Windows update, but obviously that's mostly a dream.

Thanks for any help!

1

There are 1 best solutions below

2
On BEST ANSWER

I've made an ahk function library,

to get the desktop (number) a window is on, use VD_getDesktopOfWindow(wintitle), where wintitle can be combination of WinTitle, ahk_class, ahk_exe, ahk_id, etc.

https://github.com/FuPeiJiang/VD.ahk

I've just made a script "list VD of all windows.ahk" in folder "other examples" to do what you need

It gets every window in every VD, and tells you, in order of VD, which windows are inside it.

Desktop 1: program.exe
Desktop 1: otherProgram.exe
Desktop 2: foobar.exe
Desktop 3: youGetThePoint.exe

the actual format is different

https://github.com/FuPeiJiang/VD.ahk/blob/master/other%20examples/list%20VD%20of%20all%20windows.ahk