windowsterminalvbscriptwshquake

Starting and minimizing Quake Terminal at startup


I'm trying to create a WSF that I can run using Task Scheduler at login. I want it to open the Terminal, switch to Quake mode, minimize that and then close the orignal Terminal window. I've got as far as getting the Terminal to open, and activate Quake, but I'm not sure how to shift focus to the Quake Terminal in order to minimize it and then back to the original to exit out. Best method for this - possibly not, but I'm playing around with things so I'd like to stick to this if I can.

This is what I have so far

    <package>
        <job id="vbs">
            <script language="VBScript">
                Set objShell = WScript.CreateObject("WScript.Shell")
    
                Function SendKeysTo (process, keys, wait)
                    objShell.AppActivate(process.ProcessID)
                    objShell.SendKeys keys
                    WScript.Sleep wait
                End Function
    
                Set terminal= objShell.Exec("wt")
                WScript.Sleep 500
                
                SendKeysTo terminal, "^(`)", 1000 ' Works down to here
                SendKeysTo terminal, "^(`)", 1000 ' I'm guessing this is still trying to input to the first terminal window which doesn't have focus anymore
                SendKeysTo terminal, "exit{ENTER}", 1000
            </script>
        </job>
    </package>

I have the Quake shortcut changed to Ctrl+` as it cannot simulate a WinKey press, I'm okay with this.


Solution

  • Note: This is the solution I use for your titled issue, but without the use of VBScript.

    You need to add a task to the Task Library with a trigger At Log On. The action it should perform goes as follow;
    Program/Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Add arguments: -Command wt -w _quake powershell -nologo -window minimized
    This will launch Windows Terminal in/with Quake mode, then start a Powershell process that will minimize the window.

    Source: I got this helpful tip from KKirschi from their comment.