|
voiL
中级用户
  
积分 384
发帖 189
注册 2005-10-19
状态 离线
|
『楼 主』:
[已结]谁懂VBS,帮忙做个倒计时.
使用 LLM 解释/回答一下
找了很多资料,在不用外部命令的情况下.CMD没法做出倒计时.
但我想在脚本中给用户提个醒.没办法之下只有求之于VBS了.
希望哪位路过的大虾帮帮工忙...
我要从BAT里直接写入*.VBS,然后运行之.
这个VBS只需弹出个窗口告诉用户还有多少时间可以执行操作就OK了.
致谢!
还有一问题就是:CMD的窗口能否指定坐标???
例如我想让窗口定位在屏幕的右上角.可有好的办法???
Last edited by voiL on 2006-10-21 at 02:19 ]
After searching a lot of materials, under the condition of not using external commands, CMD cannot make a countdown.
But I want to give users a reminder in the script. There's no way but to turn to VBS.
Hope some passing experts can help...
I want to directly write into *.VBS from BAT and then run it.
This VBS just needs to pop up a window to tell the user how much time is left to perform the operation. OK.
Thanks!
Another problem is: Can the CMD window specify coordinates???
For example, I want to position the window in the upper right corner of the screen. Is there a good way???
Last edited by voiL on 2006-10-21 at 02:19 ]
|
|
2006-10-15 05:18 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
@echo off
set n=10
:start
cls
echo %n%秒后自动退出
set /a n=n-1
ping -n 2 127.0.0.1>nul
if %n%==0 goto end
goto start
:end
只是记时不怎么准确
@echo off
set n=10
:start
cls
echo %n% seconds later will automatically exit
set /a n=n-1
ping -n 2 127.0.0.1>nul
if %n%==0 goto end
goto start
:end
Just the timing is not very accurate
|
|
2006-10-15 05:30 |
|
|
voiL
中级用户
  
积分 384
发帖 189
注册 2005-10-19
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
Originally posted by he200377 at 2006-10-15 05:30:
@echo off
set n=10
:start
cls
echo %n%秒后自动退出
set /a n=n-1
ping -n 2 127.0.0.1>nul
if %n%==0 goto end
goto start
:end
只是记时不怎么准确
谢谢兄台的热心回复...
但这个仅仅是个倒计时...
而我需要的并不是倒计时完了就退出这么简单...
而是让用户知道他还有多少时间可以操作...
兄的倒计时运行时,用户就不能再操作了...
你这个方法我之前也有想过...
这就是我一楼上面加红色字的部分的提问...
如果在BAT里再start另外一个BAT(倒计时)...
那么新运行的那个BAT必定会挡住之前的那个窗口(虽然可以指定窗口大小)...
但这总不是我的初衷...
最理想的就是左边是主窗口...右上角弹个小的CMD计时窗口...
我知道CMD里可以用 @mode con:cols=xx lines=xx 来指定窗口的高度和宽度,但不知有没可以指定坐标的命令...
不知哪位大虾有好的解决办法???
Last edited by voiL on 2006-10-15 at 05:54 ]
Originally posted by he200377 at 2006-10-15 05:30:
@echo off
set n=10
:start
cls
echo %n% seconds will automatically exit
set /a n=n-1
ping -n 2 127.0.0.1>nul
if %n%==0 goto end
goto start
:end
Just the timing is not very accurate
Thank you, brother, for your enthusiastic reply...
But this is just a countdown...
But what I need is not just to exit after the countdown is over...
But to let the user know how much time he has left to operate...
When your countdown runs, the user can't operate anymore...
I had thought of this method before...
This is the part of my question with red words above the first floor...
If I start another BAT (countdown) in BAT...
Then the newly running one will definitely block the previous window (although the window size can be specified)...
But this is not my original intention...
The most ideal is that the main window is on the left, and a small CMD timing window pops up in the upper right corner...
I know that in CMD, you can use @mode con:cols=xx lines=xx to specify the height and width of the window, but I don't know if there is a command to specify the coordinates...
I don't know if any expert has a good solution???
Last edited by voiL on 2006-10-15 at 05:54 ]
|
|
2006-10-15 05:42 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
是做批处理类型的答题系统?
还是批处理类型的模拟考试系统?
Is it a batch processing type of question answering system? Or a batch processing type of simulation exam system?
|

Redtek,一个永远在网上流浪的人……
_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._ |
|
2006-10-15 06:16 |
|
|
zerocq
中级用户
  
积分 458
发帖 196
注册 2006-10-5
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
楼主看看这个可以不,会出现一个窗口提醒,该窗口3秒自动消失
不知道合不合你的意?
@echo off
set /p i=多少秒提醒一次?:
set /p j=倒计时多少秒结束?:
echo wscript.sleep %i%*1000 >i.vbs
:start
cscript //nologo i.vbs
if %j% LEQ 0 del i.vbs&&goto :eof
set /a j=%j%-%i%
echo dim objshell>j.vbs
echo Set objshell = WScript.CreateObject ("WSCript.shell")>>j.vbs
echo ts =objshell.Popup("你还有%j%秒操作",3, "提示", 0 + 32)>>j.vbs
cscript //nologo j.vbs
goto :start
LZ, see if this is okay. There will be a window prompt, and this window automatically disappears after 3 seconds. I wonder if it suits your taste?
@echo off
set /p i=How many seconds for the reminder?:
set /p j=How many seconds for the countdown to end?:
echo wscript.sleep %i%*1000 >i.vbs
:start
cscript //nologo i.vbs
if %j% LEQ 0 del i.vbs&&goto :eof
set /a j=%j%-%i%
echo dim objshell>j.vbs
echo Set objshell = WScript.CreateObject ("WSCript.shell")>>j.vbs
echo ts =objshell.Popup("You still have %j% seconds to operate",3, "Reminder", 0 + 32)>>j.vbs
cscript //nologo j.vbs
goto :start
|
|
2006-10-19 00:33 |
|
|
无奈何
荣誉版主
      
积分 1338
发帖 356
注册 2005-7-15
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
这个命令是不是能完成你要的效果。
msg %USERNAME% /TIME:3 "给你三秒时间,猜猜我是谁!"
Does this command achieve the effect you want.
msg %USERNAME% /TIME:3 "You have 3 seconds to guess who I am!"
|

☆开始\运行 (WIN+R)☆
%ComSpec% /cset,=何奈无── 。何奈可无是原,事奈无做人奈无&for,/l,%i,in,(22,-1,0)do,@call,set/p= %,:~%i,1%<nul&ping/n 1 127.1>nul
|
|
2006-10-19 00:48 |
|
|
yfd11
初级用户
 
积分 44
发帖 15
注册 2006-10-18
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
@echo off
color 2f
Title=弱智制作QQ:441540230
set /p t1=请输入时间最后两位数有效:
set t2=%time% &echo 现在时间是:%time%
set/a t1=%t1:~-2%-60
if "%t1:~0,1%"=="-" set/a t1=60+%t1%
rem echo %t2:~-6,-4%
set/a t1=%t2:~-6,-4%+%t1%-60
if "%t1:~0,1%"=="-" set/a t1=%t1%+60
set t1==00%t1%
echo 到%t1:~-2,-1%%t1:~-1%秒结束.
:loop1
:loop2
if "%t1:~-2,-1%" NEQ "%time:~-5,-4%" goto :loop1
if "%t1:~-1%" NEQ "%time:~-4,-3%" goto :loop2
echo 谢谢您的使用 按任意键结束 &&pause>nul 1>nul
不过用VBS更好.
WScript.Sleep 1000(10秒)
@echo off
color 2f
Title=Stupid production QQ:441540230
set /p t1=Please enter the last two digits of the time effectively:
set t2=%time% &echo Now the time is:%time%
set/a t1=%t1:~-2%-60
if "%t1:~0,1%"=="-" set/a t1=60+%t1%
rem echo %t2:~-6,-4%
set/a t1=%t2:~-6,-4%+%t1%-60
if "%t1:~0,1%"=="-" set/a t1=%t1%+60
set t1==00%t1%
echo It will end at %t1:~-2,-1%%t1:~-1% seconds.
:loop1
:loop2
if "%t1:~-2,-1%" NEQ "%time:~-5,-4%" goto :loop1
if "%t1:~-1%" NEQ "%time:~-4,-3%" goto :loop2
echo Thank you for using, press any key to end &&pause>nul 1>nul
But VBS is better.
WScript.Sleep 1000(10 seconds)
|
|
2006-10-19 01:33 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
|
2006-10-19 01:47 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
|
2006-10-19 07:48 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
呵呵,版主的代码用的妙。
先用"start /max"命令使CMD窗口最大化到屏幕的(0,0)位置,然后再用"mode con"使其变为最小,接着一个for+ping的延时用的非常巧妙。小弟佩服。
为版主先顶4分。
Hehe, the moderator's code is cleverly used.
First, use the "start /max" command to maximize the CMD window to the (0,0) position of the screen, then use "mode con" to make it the smallest, and then a for+ping delay is very clever. Little brother admires it.
First, give the moderator 4 points.
|
|
2006-10-19 11:28 |
|
|
voiL
中级用户
  
积分 384
发帖 189
注册 2005-10-19
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
Originally posted by zerocq at 2006-10-19 00:33:
楼主看看这个可以不,会出现一个窗口提醒,该窗口3秒自动消失
不知道合不合你的意?
@echo off
set /p i=多少秒提醒一次?:
set /p j=倒计时多少秒结栮..
感谢zerocq提供的帮助.
初步试了一下兄的代码,功能是实现了.只是不能客观地给用户一个动态的提示.
不过你那个3秒后自动消失的窗口做得很新颖.收藏下来以备后用.
再次感谢.
Originally posted by zerocq at 2006-10-19 00:33:
Let the owner take a look at this, will a window pop up to remind, and this window will automatically disappear after 3 seconds
I wonder if it meets your needs?
@echo off
set /p i=How many seconds for each reminder?:
set /p j=How many seconds for the countdown to end..
Thanks to zerocq for the help.
I initially tried the brother's code, and the function is realized. However, it cannot objectively give the user a dynamic prompt.
But the window you made that automatically disappears after 3 seconds is very novel. I'll keep it for future use.
Thanks again.
|
|
2006-10-19 12:28 |
|
|
voiL
中级用户
  
积分 384
发帖 189
注册 2005-10-19
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
至于无奈何版主给出的代码在我的系统上没法完成测试.(winxp SP2)
无奈何版主的功力是有目共睹的,还望版主不吝指点一二.
因为我也是刚学批处理没多久,再加上功底浅,很多东西都没搞懂.
As for the code given by the moderator Wu Nai He, it can't be tested on my system. (WinXP SP2)
The skill of moderator Wu Nai He is obvious to all. I hope the moderator can kindly give some guidance.
Because I have just started learning batch processing for a short time, and coupled with my shallow foundation, I don't understand many things.
|
|
2006-10-19 12:32 |
|
|
voiL
中级用户
  
积分 384
发帖 189
注册 2005-10-19
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
Originally posted by yfd11 at 2006-10-19 01:33:
@echo off
color 2f
Title=弱智制作QQ:441540230
set /p t1=请输入时间最后两位数有效:
set t2=%time% &echo 现在时间是:%time%
set/a t1=%t1:~-2%-60
if "%t1:~0,1%"= ...
兄的代码我也曾写过类似的.
只是觉得没有一种明确的时间感.
往往时间到了,用户还没决定好他要做的事情.
不过兄的代码中也有不少值得学习之处.收藏以备后用.
谢谢.
Originally posted by yfd11 at 2006-10-19 01:33:
@echo off
color 2f
Title=弱智制作QQ:441540230
set /p t1=请输入时间最后两位数有效:
set t2=%time% &echo 现在时间是:%time%
set/a t1=%t1:~-2%-60
if "%t1:~0,1%"= ...
I once wrote similar code.
Just feel there is no clear sense of time.
Often when the time is up, the user hasn't decided what he wants to do.
But there are also many things to learn from your code. I'll bookmark it for future use.
Thanks.
|
|
2006-10-19 12:36 |
|
|
voiL
中级用户
  
积分 384
发帖 189
注册 2005-10-19
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
Originally posted by 3742668 at 2006-10-19 01:47:
intTime = 10
If WScript.Arguments.Count <> 0 Then intTime = WScript.Arguments(0)
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.Naviga ...
兄给出的代码完全符合了我的要求.
而且计时方式也比较客观生动.
还想请教兄一个问题:
在倒计时中,时间还没倒数到0,有何方法可以中止计时呢?
我唯一能想到的一个方法就是用Sendkeys来关闭计时窗口.
不知兄还有其它更好更稳定的方法没?
Originally posted by 3742668 at 2006-10-19 01:47:
intTime = 10
If WScript.Arguments.Count <> 0 Then intTime = WScript.Arguments(0)
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.Naviga ...
The code provided by the elder brother fully meets my requirements.
And the timing method is relatively objective and vivid.
I also want to ask the elder brother a question:
In the countdown, before the time counts down to 0, is there any way to stop the timing?
The only method I can think of is to use Sendkeys to close the timing window.
I wonder if the elder brother has other better and more stable methods?
|
|
2006-10-19 12:43 |
|
|
voiL
中级用户
  
积分 384
发帖 189
注册 2005-10-19
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
Originally posted by 3742668 at 2006-10-19 07:48:
一定要在右上角吗?左上角难道就不行?
@echo off
start /max cmd /c "title 倒数 && mode con lines=5 cols=30 && for /l %%i in (10,-1,1) do cls && ...
兄的代码真绝了,让我又受益不浅.
发完这个帖子之后.我又尝试用类似2楼兄台所提出的方法那样直接用批处理来计时.
然后另设一个指向该倒计时的快捷方式,再设置坐标来指定窗口位置.(然后用Sendkeys来中断计时器)才能达到兄代码的效果.
现兄短短的一句代码就把我几番功夫才搞定的事情给解决了.
不得不佩服兄的编程能力.
实在是太感谢了.
Last edited by voiL on 2006-10-19 at 12:51 ]
Originally posted by 3742668 at 2006-10-19 07:48:
Does it have to be in the top right corner? Can't it be in the top left?
@echo off
start /max cmd /c "title 倒数 && mode con lines=5 cols=30 && for /l %%i in (10,-1,1) do cls && ...
Brother's code is really brilliant, it has benefited me a lot again.
After posting this thread, I tried to use a similar method as proposed by the second floor brother to directly use batch processing to time.
Then set up a shortcut pointing to this countdown, and then set the coordinates to specify the window position. (Then use Sendkeys to interrupt the timer) to achieve the effect of brother's code.
Now brother's short sentence of code has solved the problem that I worked hard to get done several times.
I have to admire brother's programming ability.
Really thank you so much.
Last edited by voiL on 2006-10-19 at 12:51 ]
|
|
2006-10-19 12:47 |
|