0

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.

1
  • 1
    It will be difficult to get this working reliably with VBScript SendKeys. You may have more success using AutoIt or AutoHotKey.
    – LesFerch
    Commented Feb 6, 2023 at 15:03

4 Answers 4

3

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.

2
  • That's much simpler, and works like a charm. I'll take it, thanks. And to KKirschi too. I tried something similar originally, but didn't have powershell in my argument, think I also forgot -window and just put -minimized. I spiraled and over complicated things. Cheers again Commented Feb 10, 2023 at 9:32
  • I have not found a way to start PowerShell 7 in quakemode at startup/login. Any ideas?
    – Sam
    Commented Apr 22 at 13:27
2

Easiest way is to create a shortcut for your user at login. Can even be done without the mouse.

  1. Open your user's Startup folder: Win + R -> shell:startup

  2. In Explorer window, create a new shortcut: ALT + F, W, S

  3. Enter the following:

    wt -w _quake powershell -window minimized
    
  4. Give it a name, like Quake Mode Terminal.

Feel free to add any other commands. I personally like starting with a split window. Add sp after _quake.

0

For those that want to use TDarkshadows answer but want to use Powershell 7, this worked for me.

Program/Script: "C:\Program Files\PowerShell\7\pwsh.exe"
Add arguments: -Command wt -w _quake pwsh -nologo -window minimized

0

I have a OS setup script which does various stuff including installing NirCmd which can various things including make shortcuts.

So after installing NirCmd using scoop, I have a few lines which make startup shortcuts, including this one for Windows Terminal, starting hidden and in Quake Mode.

nircmd shortcut "%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe" "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup" "Quake Terminal" "-w _quake -p ~qCommand Prompt~q" "%USERPROFILE%\winfiles\icons\app_icons\terminal.ico" "" min

Anyone who uses this will have to replace the following part with a path to the icon they wish to use.

"%USERPROFILE%\winfiles\icons\app_icons\terminal.ico"

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