The windows that I am trying to minimise are already running so start /min
is not an option.
Asked
Active
Viewed 125 times
-1

rowanphilip
- 319
- 5
- 16
-
1what have you tried on your own? Please read [tour](http://stackoverflow.com/tour) and [how to ask](http://stackoverflow.com/help/how-to-ask) – elzooilogico Sep 15 '16 at 09:50
-
Batch commands are not capable of window controlling. You might be interested in [AutoIt](http://autoitscript.com) or [AutoHotkey](http://autohotkey.com)... – aschipfl Sep 15 '16 at 10:05
1 Answers
1
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

elzooilogico
- 1,659
- 2
- 17
- 18