运行BATCH时,最小窗口并返回最大化

时间:2012-08-25 22:21:12

标签: batch-processing batch-file

我无法找到解决问题的好方法。也许有人已经得到答案,并且非常友好地分享它。我正在运行批处理文件,并且在某个时间,我想最小化批处理窗口。稍后一些代码,最大化或将其返回到实际大小。

@echo off
mode con cols=100 lines=100
echo My batch is NOT minimized. This message is from a normal window! 
start "window_will_be_minimized" k:\Folder20\MiniMaxi.exe 
start /wait "" cmd /c c:\Folder00\Drawing.exe

现在正在运行Drawing.exe。

REM --- At this point my batch window is minimized and the MiniMaxi.exe is closed
REM --- until the Drawing.exe is closed.

Drawing.exe现已关闭。

REM --- Immediatelly my batch window must return to its previous size.
        Therefore, the MiniMaxi.exe will be launched and then closed

start "window_will_be_MAXImized" k:\Folder20\MiniMaxi.exe
echo Again, this message is from a normal window
pause > nul
exit /b

提前谢谢

2 个答案:

答案 0 :(得分:0)

坏消息:批处理文件无法控制自己的窗口是min还是max;这必须在调用批处理文件时完成,此时您可以告诉它运行/ min,/ max或者两者都不是/ default。新批次不会知道此设置。正如EitanT所提到的,它必须由应用程序管理。只有在启动新批次时,您才可以控制 是否为最小,最大或正常。

对于计时,你唯一的控制就是暂停(就像你在脚本中所做的那样),或者通过做大约10秒的延迟来延迟脚本延续的一些方法:

ping -n 10 localhost >nul

答案 1 :(得分:0)

我无法按照您的要求执行操作,但如上所述,您可以在最小化最大化默认状态下生成批处​​理文件。以下内容将创建一个新批处理(function (){ var div = $('#myDiv'), infiniteScroll = function () { //---gets the bottom of the page value var bottomHeight = div[0].scrollHeight; var callback1 = function () { //once it gets into this callback function //it resets the position to zero div.scrollTop(0); //invokes again the function infinite scroll infiniteScroll(); }; div.animate({scrollTop:bottomHeight},20000,callback1) }; //starts the function for the very first time infiniteScroll(); })(); 启动最小化&出口。新批处理xmise.bat将启动Drawing.exe,等待,启动原始批处理(自定义大小的窗口)&出口。然后原始批次将删除创建的批次xmise.bat

你可以写

  

某些代码以后/隐藏“清理”功能

到xmise.bat

xmise.bat

现在正在运行Drawing.exe。

@echo off
mode con cols=100 lines=100
if "%var%"=="" echo My batch is NOT minimized. This message is from a normal window!
if "%var%"=="created" echo Again, this message is from a normal window
pause>nul 
if "%var%"=="created" del xmise.bat&cls&goto :end
set var=created
echo start /wait "" "Drawing.exe">xmise.bat
echo start "" cmd /c "%~n0.bat">>xmise.bat
echo exit>>xmise.bat
start /min xmise.bat
:end
exit

Drawing.exe现已关闭。

REM --- At this point the xmise.bat window is minimized and the original.bat (%~n0.bat) exits
REM --- until the Drawing.exe is closed.