英文:
Starting and minimizing Quake Terminal at startup
问题
我正在尝试创建一个可以在登录时使用任务计划程序运行的WSF(Windows Script File)。我希望它能打开终端,切换到 Quake 模式,将其最小化,然后关闭原始终端窗口。
我已经成功打开终端并激活 Quake 模式,但不确定如何将焦点切换到 Quake 终端以最小化它,然后再切回原始终端以退出。
这可能不是最佳方法,但我正在尝试不同的方法,所以我想坚持这个方法。
到目前为止,我已经有以下代码:
<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 ' 这一部分是有效的
SendKeysTo terminal, "^(`)", 1000 ' 我猜这仍然尝试输入到第一个失去焦点的终端窗口
SendKeysTo terminal, "exit{ENTER}", 1000
</script>
</job>
</package>
我已将 Quake 快捷方式更改为 Ctrl+`,因为它无法模拟 WinKey 按键,这对我来说是可以接受的。
英文:
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
得分: 3
注意:这是我为您提出的问题提供的解决方案,但是没有使用VBScript。
您需要在任务库中添加一个触发器为“在登录时”(At Log On)的任务。
它应该执行以下操作:
程序/脚本:C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
添加参数:-Command wt -w _quake powershell -nologo -window minimized
这将以Quake模式启动Windows Terminal,然后启动一个将窗口最小化的Powershell进程。
英文:
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
得分: 2
最简单的方法是在登录时为您的用户创建一个快捷方式。甚至可以在没有鼠标的情况下完成。
-
打开您的用户的启动文件夹:
Win + R
->shell:startup
-
在资源管理器窗口中,创建一个新的快捷方式:
ALT + F, W, S
-
输入以下内容:
wt -w _quake powershell -window minimized
-
给它起个名字,比如Quake Mode Terminal。
随时添加其他命令。我个人喜欢从一个分割窗口开始。在_quake
后面添加sp
。
英文:
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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论