you should put VD.ahk in your standard library: for me it's "C:\Program Files\AutoHotkey\lib"
https://www.autohotkey.com/docs/Functions.htm#lib
I've moved the code to github:
https://github.com/FuPeiJiang/VD.ahk
the function library is : "VD.ahk":
https://raw.githubusercontent.com/FuPeiJiang/VD.ahk/master/VD.ahk
some examples (change the wintitles to your choice) "VD examples.ahk":
https://raw.githubusercontent.com/FuPeiJiang/VD.ahk/master/VD%20examples.ahk
Just run the examples, everything explained inside
Edit:
added ; VD_getCount() ;this will return the number of virtual desktops you currently have
Edit 2: FIXES:
1)annoying flash 2)VD_sendToCurrentDesktop crash 3)global vars
1) switching desktop causes focused window to blink in taskbar
https://github.com/mzomparelli/zVirtualDesktop/issues/59#issuecomment-317613971
so I winactivate the taskbar and then when I arrive at new Virtual Desktop, I emulate alt-tab.
2) Added VD_isValidWindow(hWnd) to only select valid window : It wasn't working for ("ahk_exe devenv.exe")
3) renamed some global vars
Edit 3: FIXED: sometimes SwitchDesktop will altTab into another window
after arriving, winactivate taskbar before altTab
Edit 4: completely fixed VD_SwitchDesktop(): altTab, not switching
renamed VD_getCurrentVirtualDesktop() -> VD_getCurrentDesktop()
removed VD_AltTab()
added VD_isWindowFullScreen(winTitle)
added VD_getCurrentIVirtualDesktop()
WinMinimize, ahk_class Shell_TrayWnd
instead of altTabing
SwitchDesktop twice when in fullscreen apps
VD.ahk : Virtual Desktop (move window, go to VD of your choice instantly, get Which VD you are in, etc.)
VD.ahk : Virtual Desktop (move window, go to VD of your choice instantly, get Which VD you are in, etc.)
Last edited by MrDoge on 05 Jan 2021, 20:47, edited 6 times in total.
Re: VD.ahk : Virtual Desktop (move window, go to VD of your choice instantly, get Which VD you are in, etc.)
Great except for all the globals you're introducing.
Re: VD.ahk : Virtual Desktop (move window, go to VD of your choice instantly, get Which VD you are in, etc.)
can I avoid calling VD.init() if I used a class instead ?
can the class call VD.init() by itself when I #include it ?
by call VD.init(), I mean assign the variables
reasons I don't like using class :
1)non global vars, so I need to this.Var instead of Var
2)I would have to
#include <VD>
VD.init()
instead of
VD_init()
can the class call VD.init() by itself when I #include it ?
by call VD.init(), I mean assign the variables
reasons I don't like using class :
1)non global vars, so I need to this.Var instead of Var
2)I would have to
#include <VD>
VD.init()
instead of
VD_init()
Re: VD.ahk : Virtual Desktop (move window, go to VD of your choice instantly, get Which VD you are in, etc.)
You may be able to avoid it if the class is used in a static fashion. You’d just have to have an internal property to determine if it has been initialized yet, and if not, self initialize.
Re: VD.ahk : Virtual Desktop (move window, go to VD of your choice instantly, get Which VD you are in, etc.)
@MrDoge - Looks promising! Just out of curiosity (I‘ve might have missed it), is there any indicator (like array.Length() for arrays) that is telling us the number of virtual screens/desktops currently available?
PS. I’m thinking about to use it with this: matricapp.com
PS. I’m thinking about to use it with this: matricapp.com

Re: VD.ahk : Virtual Desktop (move window, go to VD of your choice instantly, get Which VD you are in, etc.)
@kczx3 what is a non-static fashion ?
I could check it using this (in front of every function) :
IfNotEqual, true, this.initialized, this.init()
but what if the init() takes a long time... I want to call it at the start of script (at the end of the autoexecute section), instead of calling init() when I need to use another function.
is there a onInclude() method ? so it is called when the class is included, instead of __New() (which is called when a new instance is created)
well this isn't that bad, it's one 1 line more than function library
I don't see a problem with global variables, does it slow down the script ?
@BoBo
thanks for telling me, I haven't thought about this.
the script has A LOT of duplicate code, but it works so ...
I've edited the 1st post, added VD_getCount()
what extra use can matricapp.com provide if I already have hotkeys ? (extra buttons ?)
I could check it using this (in front of every function) :
IfNotEqual, true, this.initialized, this.init()
but what if the init() takes a long time... I want to call it at the start of script (at the end of the autoexecute section), instead of calling init() when I need to use another function.
is there a onInclude() method ? so it is called when the class is included, instead of __New() (which is called when a new instance is created)
well this isn't that bad, it's one 1 line more than function library
#include <VD>
VD := new VD()
VD := new VD()
I don't see a problem with global variables, does it slow down the script ?
@BoBo
thanks for telling me, I haven't thought about this.
the script has A LOT of duplicate code, but it works so ...
I've edited the 1st post, added VD_getCount()
what extra use can matricapp.com provide if I already have hotkeys ? (extra buttons ?)
Re: VD.ahk : Virtual Desktop (move window, go to VD of your choice instantly, get Which VD you are in, etc.)
Every single one of those functions are global. So if any of your variable names clash with a consumers, you will overwrite their variables, or they could overwrite yours.
Re: VD.ahk : Virtual Desktop (move window, go to VD of your choice instantly, get Which VD you are in, etc.)
@MrDoge -
That might be interesting for those who are not able/willing to remember a thousand different hotkeys (that might often end up duplicated if used for different applications).
So you can use whatever Android device to remote control whatever application on your PC. And yes, these (button) decks can be created/designed by yourself.
Thx for implementing that feature, much appreciated
Matric is providing an 'auto switcher-option that will swap to a predefined deck (ie for OBS/YouTube/Netflix/...) once its assigned application at the PC gets the focus.what extra use can matricapp.com provide if I already have hotkeys ? (extra buttons ?)
That might be interesting for those who are not able/willing to remember a thousand different hotkeys (that might often end up duplicated if used for different applications).
So you can use whatever Android device to remote control whatever application on your PC. And yes, these (button) decks can be created/designed by yourself.
Thx for implementing that feature, much appreciated
