启动并将Quake终端在启动时最小化。

huangapple go评论64阅读模式
英文:

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

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

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进程。

来源:我从KKirschi评论中得到了这个有用的提示。

英文:

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

最简单的方法是在登录时为您的用户创建一个快捷方式。甚至可以在没有鼠标的情况下完成。

  1. 打开您的用户的启动文件夹:Win + R -> shell:startup

  2. 在资源管理器窗口中,创建一个新的快捷方式:ALT + F, W, S

  3. 输入以下内容:

     wt -w _quake powershell -window minimized
    
  4. 给它起个名字,比如Quake Mode Terminal

随时添加其他命令。我个人喜欢从一个分割窗口开始。在_quake后面添加sp

英文:

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.

huangapple
  • 本文由 发表于 2023年2月6日 20:05:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75361094.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定