中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-27 14:07
47,813 topics / 349,918 posts / today 0 new / 48,276 members
DOS批处理 & 脚本技术(批处理室) » DOS clock made while working on the job
Printable Version  2,503 / 18
Floor1 bat-zw Posted 2008-03-10 18:30
金牌会员 Posts 1,276 Credits 3,105
You can add a reminder function, such as reminding what to do when a certain time comes. Due to my time constraints, I posted in a hurry, please bear with me and put forward valuable opinions. The purpose of each of my posts is to focus on the theme of common improvement. The code is as follows:
@echo off
:begin
mode con cols=40 lines=3&setlocal EnableDelayedExpansion
title dos clock
set /a a=%random%/3640&set /a b=%random%/3640
cls&color %a%%b%&echo.&echo.&echo.&echo    %date% !time:~-11,-3!&ping/n 2 127.1 >nul
goto begin
Floor2 bat-zw Posted 2008-03-10 18:52
金牌会员 Posts 1,276 Credits 3,105
Added reminder function and modified error codes:
@echo off&setlocal EnableDelayedExpansion
:begin
mode con cols=40 lines=3
title dos clock
set t=!time:~-11,-6!
if "%t%"=="18:00" goto show
set /a a=%random%/3640&set /a b=%random%/3640
cls&color %a%%b%&echo.&echo.&echo.&echo    %date% !time:~-11,-3!&ping/n 2 127.1 >nul
goto begin
:show
cls&color 9f&echo.&echo.&echo.&echo    It's time to get off work!
goto begin

[ Last edited by zw19750516 on 2008-3-10 at 07:14 PM ]
Floor3 plp626 Posted 2008-03-10 19:51
银牌会员 Posts 1,020 Credits 2,278
The building owner is really cute, I guess it's a girl (I have no bad intentions)
Floor4 plp626 Posted 2008-03-10 20:03
银牌会员 Posts 1,020 Credits 2,278
Only after checking the information did I realize the original poster is a handsome guy. Sorry about that. The post has great ideas, so I'll give a thumbs up here.
Floor5 suntb Posted 2008-03-10 22:27
高级用户 Posts 277 Credits 581
Tested it, and the effect is pretty good
Floor6 tempuser Posted 2008-03-12 19:14
高级用户 Posts 261 Credits 547
Originally posted by zw19750516 at 2008-3-10 18:52:
Added reminder function and modified error code:
@echo off&setlocal EnableDelayedExpansion
:begin
mode con cols=40 lines=3
title dos clock
set t=!time:~-11,-6!
if "%t%"==&quo ...


Spent two hours thinking I understood the %var:~1,5% usage of set, but how to understand
=!time:~-11,-6!
For example, the result of entering the time command is:
18:20:55.75
How to intercept it?
Floor7 sea1112 Posted 2008-03-12 20:10
初级用户 Posts 119 Credits 131 From gz
set t=!time:~-11,-6! can be changed to set t=!time! directly
Floor8 bat-zw Posted 2008-03-12 22:18
金牌会员 Posts 1,276 Credits 3,105
Originally posted by tempuser at 2008-3-1期间19:14:


Spent two hours thinking I understood the usage of %var:~1,5% in set, but
=!time:~-11,-6!
How to understand it?
For example, the result of entering the time command is:
18:20:55.75
How to intercept it?

Actually, the system time is composed of 11 characters. The command!time:~-11,-6! means to intercept 11 characters from the time starting from the back and discard 6 characters from the back. For 18:20:55.75, the intercepted characters are 18:20. It seems you are not very familiar with the character interception command. Here is a practice tool for you: http://www.cn-dos.net/forum/viewthread.php?tid=38251&fpage=4, I believe you will be familiar with it in a short time.
Floor9 jiudun Posted 2008-03-13 01:45
初级用户 Posts 40 Credits 98
Floor10 tempuser Posted 2008-03-13 12:12
高级用户 Posts 261 Credits 547
Originally posted by zw19750516 at 2008-3-12 22:18:

Actually, the system time is composed of 11 characters. The meaning of the!time:~-11,-6! command is to intercept 11 characters from the time's 11 characters from the back and discard 6 characters from the back. For 18:20:55.75 intercepting...

Different understanding, but this tool is not enough to enhance my understanding because there are no negative numbers
I don't know if my understanding is correct, but I still think this understanding is fast. For example, you said
%var:~5,5%
Intercept 5 from the front and 5 from the back
My understanding is
Start from the 6th character, intercept 5 and assign to the variable, no matter right or wrong, but it is very clear
Floor11 bat-zw Posted 2008-03-17 18:48
金牌会员 Posts 1,276 Credits 3,105
@echo off&setlocal EnableDelayedExpansion
:begin
mode con cols=40 lines=3
title dos clock
set t=!time:~-11,-6!
if "%t%"=="12:00" goto show
if "%t%"=="18:00" goto show
set /a a=%random%/2184&set /a b=%random%/2184
if "%a%"=="15" set a=f
if "%a%"=="14" set a=e
if "%a%"=="13" set a=d
if "%a%"=="12" set a=c
if "%a%"=="11" set a=b
if "%a%"=="10" set a=a
if "%b%"=="15" set b=f
if "%b%"=="14" set b=e
if "%b%"=="13" set b=d
if "%b%"=="12" set b=c
if "%b%"=="11" set b=b
if "%b%"=="10" set b=a
cls&color %a%%b%&echo.&echo.&echo.&echo    %date% !time:~-11,-3!&ping/n 2 127.1 >nul
goto begin
:show
cls&color 9f&echo.&echo.&echo.&echo    It's time to get off work!
goto begin
Floor12 ngd Posted 2008-03-18 20:14
中级用户 Posts 108 Credits 312
Not bad!
Can be strengthened a bit more. Add sound prompt.
Use bell to ring (enter ctrl+g in cmd)
Or call mshta
Floor13 bat-zw Posted 2008-03-19 13:24
金牌会员 Posts 1,276 Credits 3,105


[ Last edited by zw19750516 on 2008-3-19 at 01:27 PM ]
Floor14 zsj008od Posted 2008-03-19 20:51
初级用户 Posts 12 Credits 28
Learning mshta vbscript:createobject("sapi.spvoice").speak("time is go home")(window.close)
This is pretty good
Floor15 zsj008od Posted 2008-03-19 20:51
初级用户 Posts 12 Credits 28
Here is the translation of the provided content:

Here is a VBS script that can speak both Chinese and English.
Set objVoice = CreateObject("SAPI.SpVoice")
Set objVoice.Voice = objVoice.GetVoices("Name=Microsoft Mary").Item(0)
objVoice.Speak "Hi, this is Microsoft Mary"
Wscript.Sleep 2000
Set objVoice.Voice = objVoice.GetVoices("Name=Microsoft Simplified Chinese").Item(0)
objVoice.Speak "Hello, today is Sunday Hi, this is Microsoft Mary"
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023