FuPeiJiang / VD.ahk

Windows Virtual Desktop, AutoHotkey, Windows 11 support, Windows Server 2022, switch desktop, move window(wintitle) to current desktop; createDesktop, PinWindow, getCount, getDesktopNumOfWindow -> mute all windows in Virtual Desktop
MIT License
319 stars 45 forks source link

open Application directly on one virtual desktop in background #50

Open mmaukii opened 11 months ago

mmaukii commented 11 months ago

i am using your library and i love it!!!! I also build something, which sets up windows on the right desktops when i start up the pc. But it is not really relaiable and taks some time an i wanted to ask if there is a better possibility to for example start the notepad directly on desktop 3. At the moment i open the app and push it than to the desktop:

Run,notepad.exe , , Min, OutputVarPID WinWait ahk_pid %OutputVarPID% VD.MoveWindowToDesktopNum("A",3)

Would be happy about some help

FuPeiJiang commented 11 months ago

but this should be more reliable:

start notepad.ahk:

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance force
ListLines Off
SetBatchLines -1
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#KeyHistory 0
#WinActivateForce

Process, Priority,, H

SetWinDelay -1
SetControlDelay -1

#Include %A_LineFile%\..\..\VD.ahk

Run notepad.exe, , ,OutputVarPID
loop {
    found:=VD._tryGetValidWindow("ahk_pid " OutputVarPID)
    if (found) {
        break
    }
    Sleep 10
}
VD.MoveWindowToDesktopNum("ahk_pid " OutputVarPID, 3)

return

f3::Exitapp
mmaukii commented 11 months ago

Your sir, are a genius! Thanks a lot!!!!