UPDATED-STATEMENT: 20181118@205016@SUN A suggestion was made to manually focus the Virtual Desktop of my choice, but this eliminates me from doing other tasks on another Virtual Desktop. Still waiting for a valid take-care-ofitself solution.
UPDATED-STATEMENT: 20181118@210851@SUN There is no way autohotkey can work with moving apps to a specific Virtual Desktop on it's own without dll-calls (*see below*). In other words, the use of dll-files is required for the time being that is Windows language and not as convenient as an ahk-statement. Who knows, maybe ahk can implement this function someday to keep it lightweight and add it to their statement-library.

Speed is everything if it does affect you sitting on your chair in front of a computer screen.


Using Autohotkey in Windows 10 to open up frequently used apps which will not duplicate opening up a program if it has already launched (IfWinNotExist). Then, move them to where I prefer each app to be (WinMove). I have set a timer (Sleep) because some apps open up slower than others (I would be interested to know if there is a better way to do this). I like ahk for how lightweight it is, but there's Windows 10 related functions that aren't documented from them like Virtual Desktop involvement.


Problem is that there isn't a way to use WinMove for specifying a Virtual Desktop for win10 to launch an application in. So I struggle running my frequentlyusedapps-script and going into another Virtual Desktop to open up other apps simultaneously. This is because what ever Virtual Desktop i'm focusing on is what my frequentlyusedapps-script will move the window to.


How to have autohotkey move an application to a Virtual Desktop of my choice? I don't think it's possible with ahk-WinMove If the virtualdesktop-number isn't created then the script will obviously fail to move the app, but this isn't my focus just yet. I could otherwise create the appropriate number of Virtual Desktops prior to launching my frequentlyusedapps-script. What I mean by having a way for ahk to achieve this is to be pure ahk code and not fork/branch that will probably be not updated for the unfortunate reasons. If it does have to come from a branched project then let's discuss what ahk elements they're using to involve Virtual Desktop to move windows to a specific one.

  IfWinNotExist, ahk_exe program1.exe
    Run "C:\Dir\program1.exe"
    WinWait, ahk_exe program1.exe
    WinMove, ahk_exe program1.exe,, 953, 61, 967, 1019
    TrayTip, openfrequentlyusedapps, ok, 1,
  IfWinNotExist, ahk_exe program2.exe
    Run "C:\Dir\program2.exe"
    WinWait, ahk_exe program2.exe
    WinMove, ahk_exe program2.exe,, -7, 61, 813, 516
    TrayTip, openfrequentlyusedapps, ok, 1,


  • As per @miroxlav, "there is no way Autohotkey can do this with their current statements." Although not impossible, but requires more effort as it's now Windows language is using ahk w/ dll-calls.
    • It would help a lot of someone is able to show how this even works
  • 1
  • 1
    I wanted to stick with the roots of ahk and not a branch away from it's core (due to branding). What do you think this yet another enhancer uses to move windows to another desktop? Because I noticed the use of dll-files which isn't lightweight anymore. – fohrums Nov 17 at 22:31
  • What's wrong with using dll-files to facilitate or even make possible the execution of tasks if they come from a secure site?. No program can execute all its functions and various features using its own modules or resources. And dll-files are files that contains specific code that many installed programs use and share. – user3419297 Nov 18 at 19:54
  • How do you even know those dll-files online are even secured? If getting dll-files from another software, then that only means you have to have the software which is impossible to obtain if you don't have it in the first place especially if you don't have internet at the time being. I really meant it when I talked about using ahk and it being "lightweight". I just need help on using dll-calls and what dll-files are required as dependencies to move windows to a specific virtual desktop. – fohrums Nov 18 at 21:29

Go with keyboard shortcuts.

Inside the script, when you sequentially start your apps, in the middle of your sequence simply switch to the next desktop by sending Ctrl+Win+:

;here you run and position your windows
Run app1
Move app1  'etc.
WinWait app1window   'wait until app window is open

;switch to next desktop*  (see note below the code)
Send ^#{Right}

;opening apps on next desktop
Run app2
Move app2  'etc.

*) If you do not have that "next desktop" prepared at the time, send Ctrl+Alt+D instead to create and open it.

For more, see section Virtual desktops keyboard shortcuts in the official list of Windows keyboard shortcuts.


Functionality regarding other desktops as you request it is currently not present directly in AHK statements. You may be able to achieve it by using DLL calls from within the AHK.

  • That's an action after an action which only means I still have to be focused on the desktop I want the windows to so happen to land in once opened. This eliminates me from going into another virtual desktop simultaneously to do other tasks while I wait for slow apps to launch (but, thanks for letting me know about ahk-WinWait so I replaced ahk-Sleep with it instead). – fohrums Nov 18 at 10:49
  • That's not a problem for me I don't know why it would be. Virtual Desktop is marvelous for being able to simulate working on multiple computers but using just a single rig. I don't know the limit of how many is workable, but I then would use another Virtual Desktop to continue opening up other apps. I hope this answers you're concern. – fohrums Nov 18 at 11:00
  • Thanks for the help @miroxlav, I just needed to know that. I thought there was some hidden command that I had to dig up in order to achieve this, but it looks like it's farily new. I imagine AHK could make this possible some day as Windows 10 has been released for over 3-yrs now. Virtual Desktop doesn't seem like it's going to go away anytime soon so it's good I began this topic. – fohrums Nov 18 at 11:08

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.