Reputation: 23
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.
Upvotes: 2
Views: 3842
Reputation: 288
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"
Upvotes: 0
Reputation: 21
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
Upvotes: 2
Reputation: 757
Easiest way is to create a shortcut for your user at login. Can even be done without the mouse.
Open your user's Startup folder: Win + R
-> shell:startup
In Explorer window, create a new shortcut: ALT + F, W, S
Enter the following:
wt -w _quake powershell -window minimized
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
.
Upvotes: 5
Reputation: 66
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.
Upvotes: 5