How would I write a batch script to either minimis

2019-12-16 20:32发布

The windows that I am trying to minimise are already running so start /min is not an option.

1条回答
时光不老,我们不散
2楼-- · 2019-12-16 21:14

It can be done with an vbscript hybrid.

@echo off

set "lookFor=Calculator"

for /f "tokens=2 delims=," %%A in ('tasklist /nh /fo csv /fi "WINDOWTITLE eq %lookfor%"') do set "pid=%%~A"

>"%TEMP%\_edit.vbs" (
  echo/Set oShell = CreateObject("WScript.Shell"^)
  echo/oShell.AppActivate %pid%
  echo/WScript.Sleep 500
  echo/oShell.SendKeys "%% (n)" ' minimize (Alt+SpaceBar,n^)
)

start /B cmd /C "CScript //nologo //E:vbs "%TEMP%\_edit.vbs" & rem del /F /Q "%TEMP%\_edit.vbs" 2>NUL"

exit/B
查看更多
登录 后发表回答