Function: Determine the geographical location based on the IP, then obtain the 72-hour weather forecast for the corresponding area.
One very obvious shortcoming is:
It's really hard to handle the layout when controlling the variable output``Although the effect is good, it's a bit forced. I hope experts can give better solutions or algorithms.
Key effect screenshots:

It can also be downloaded from here: http://kumho.lin.googlepages.com/WeatherCapturer.bat
--------------------------------------------------------------------------------------------------
Update:
1. With the help of slore, the full-screen effect is realized
Defect:
The method of modifying the registry and then passing parameters to call the batch script itself seems not so smooth for my batch script. Some variables cannot be obtained. It is definitely not because of slow network speed, because I run the batch script in the default window size, and then press ALT+ENTER, which is also full screen, and can normally obtain the corresponding variables. These variables need to be obtained online.
The effect of running my updated code is as follows:
[ Last edited by dosmania on 2007-9-23 at 07:38 PM ]
One very obvious shortcoming is:
It's really hard to handle the layout when controlling the variable output``Although the effect is good, it's a bit forced. I hope experts can give better solutions or algorithms.
Key effect screenshots:

It can also be downloaded from here: http://kumho.lin.googlepages.com/WeatherCapturer.bat
@echo off
if "%1"=="" goto :FullScreen
::Restore display mode
REG ADD HKEY_CURRENT_USER\Console /v FullScreen /t REG_DWORD /d %1 /f>nul
cls
title Intelligent Acquisition of 72-Hour Weather Forecast --- Tencent Version Code By Kumho Lin
color 0b
setlocal EnableDelayedExpansion
set "a=FileName: WeatherCapturer.exe"
set "b=FileVersion: 1.0.0.1"
set "c=Function: Get the weather information in 72 hours according to your location"
set "d=Author: Kumho Lin"
set "e=QQ: 240460440"
set "f=E-Mail: kumho.lin@gmail.com"
set "g=HomePage: http://kumho.lin.googlepages.com"
set "h=Are you sure you wanna run this batch program right now ?"
for %%i in (a b c d e f g h) do (
set/p=<nul
for /l %%a in (0,1,100) do (
if not "!%%i:~%%a,1!"=="" (
if "%%a"=="100" echo.&echo;
set/p=!%%i:~%%a,1!<nul
for /l %%p in (1,1,200) do ver>nul
)
)
echo.
)
set /p choice=
if /i "%choice%"=="y" (goto Begin) else goto Out
:Out
exit
:Begin
cls
ping -n 2 127.1 >nul 2>nul
:: →→→→→→→→→→→→→ Loading The Program ←←←←←←←←←←
(set,=Loading the program, please wait a minute&for /l %%c In (0,1,42)do @call set/p=%%,:~%%c,1%%<nul)&set,=&ping -n 2 127.1>nul&set/p="."<nul&ping -n 2 127.1>nul&set/p="."<nul&ping -n 2 127.1>nul&set/P="."<nul&ping -n 3 127.1>nul
cls
set num=20
set a==
set n=1
for /l %%i in (1,1,80) do (
cls
set /a num+=1
echo !num!%%
echo !a!
set a=!a!=
set /a n+=1
for /l %%j in (1,1,150) do ver>nul
)
ping -n 1 127.1 >nul 2>nul
echo Loading Complete
ping -n 2 127.1 >nul 2>nul
endlocal
cls
:: →→→→→→→→→→→→→ Loading The Program ←←←←←←←←←←
:: ************************** Determine whether connected to the Internet *****************************
setlocal EnableDelayedExpansion
set a=The program is detecting your system, please wait a minute...
for %%i in (a) do (
set/p=<nul
for /l %%a in (0,1,100) do (
if not "!%%i:~%%a,1!"=="" (
if %%a==100 echo.&echo;
set/p=!%%i:~%%a,1!<nul
for /l %%i in (1,1,100) do ver>nul
)
)
echo.
)
endlocal
ping -n 2 127.1>nul 2>nul
cls
ping -n 2 www.ip138.com >nul 2>nul
if %errorlevel% equ 0 (goto ready) else goto problem
:problem
setlocal DisableDelayedExpansion
set "A= Your computer is not connecting to the Internet !!!"
set "B="
for /l %%j in (1,1,10) do (
set/p=%A%<nul
set/p=%B%<nul
for /l %%i in (1,1,500) do ver>nul
set/p= <nul
for /l %%i in (1,1,500) do ver>nul
set/p=%B%<nul
ping -n 1 127.1 >nul 2>nul
)
endlocal
MSG * /time:3 ***** You must be connected to the Internet to use this function *****
goto quit
:ready
echo The batch program is connecting to the Internet, please wait a few seconds...
ping -n 4 127.1>nul 2>nul
cls
:: ==================== Start of script to obtain IP, geographical location and ISP ===================
echo Set oDOM = WScript.GetObject(WScript.Arguments(0))>%TEMP%\Text.vbs
echo Do Until oDOM.readyState = "complete">>%TEMP%\Text.vbs
echo WScript.sleep 200>>%TEMP%\Text.vbs
echo Loop>>%TEMP%\Text.vbs
echo WScript.echo oDOM.documentElement.outerText>>%TEMP%\Text.vbs
echo Set oDOM=nothing>>%TEMP%\Text.vbs
cscript //NoLogo /E:vbscript %TEMP%\Text.vbs http://www.ip138.com | find /i "Your IP address is" 2>nul>%TEMP%\location.txt
for /f "tokens=2 delims=" %%i in (%TEMP%\location.txt) do set true_ip=%%i
for /f "tokens=2,3 delims= " %%k in (%TEMP%\location.txt) do (
set your_location=%%k
set true_isp=%%l
)
echo %your_location:~3,-1%>%TEMP%\your_location.txt
for /f "tokens=1,2 delims=省" %%p in (%TEMP%\your_location.txt) do (
set true_province=%%p
set true_city=%%q
)
:: ==================== End of script to obtain IP, geographical location and ISP ===================
:: ************************* Start of script to obtain temperature information ***********************
cscript //nologo /e:vbscript %TEMP%\Text.vbs http://kumho.lin.googlepages.com/city.txt|find /v /i "javascript" 2>nul>%TEMP%\cityInfo.txt
for /f "tokens=1 delims=/" %%i in ('find /i "%true_city%" %TEMP%\cityInfo.txt') do set cityCode=%%i
set "cityAddress=http://weather.news.qq.com/inc/07_dc%cityCode%.htm"
echo Set oDOM = WScript.GetObject(WScript.Arguments(0))>%TEMP%\HTML.vbs
echo Do Until oDOM.readyState = "complete">>%TEMP%\HTML.vbs
echo WScript.sleep 200>>%TEMP%\HTML.vbs
echo Loop>>%TEMP%\HTML.vbs
echo WScript.echo oDOM.documentElement.outerHTML>>%TEMP%\HTML.vbs
echo Set oDOM=nothing>>%TEMP%\HTML.vbs
cscript //nologo /e:vbscript %TEMP%\HTML.vbs %cityAddress% 2>nul>%TEMP%\source.txt
:: ******** Code to obtain temperature information ********
Setlocal EnableDelayedExpansion
set a=1
for /f "tokens=4 delims= " %%i in ('type %TEMP%\source.txt^|find /i "#eef3f8"') do (
set var=%%i
set string=!var:~10!
set num=!string:^<BR^>=#!
for /f "tokens=1,2 delims=#" %%a in ("!num!") do (
set tq!a!=%%a
set wd!a!=%%b
)
set /a a+=1
)
endlocal
:: ******** Code to obtain date information ********
Setlocal EnableDelayedExpansion
set b=1
for /f "tokens=4 delims=, " %%i in ('type %TEMP%\source.txt^|find /i "#eeeeee"') do (
set time1=%%i
set time2=!time1:^>=#!
set time3=!time2:^<=#!
for /f "tokens=2 delims=#" %%a in ("!time3!") do set rq!b!=%%a
set /a b+=1
)
endlocal
:: ************************* End of script to obtain temperature information ***********************
:: /*-*-*-*-*-*-*-*-*-*-* Start of script to obtain operating system version information *-*-*-*-*-*-*-*-*-*-*/
Systeminfo 2>nul >%TEMP%\systeminfo.txt
type %TEMP%\systeminfo.txt | Find /I /V "BIOS 版本:" >%TEMP%\eol.txt
For /F "tokens=3*" %%I in ('type %TEMP%\systeminfo.txt ^| Find /I "OS 名称:"') Do Set os_name=%%I %%J
For /F "tokens=3,4,5,6 delims= " %%i in ('type %TEMP%\eol.txt ^| Find /I "OS 版本:"') Do Set os_ver=%%i %%j %%k %%l
Set os_name_ver=%os_name% %os_ver%
:: /*-*-*-*-*-*-*-*-*-*-* End of script to obtain operating system version information *-*-*-*-*-*-*-*-*-*-*/
:: ------------------------- Start of variable display layout code -----------------------
:: -------- Start of variable comments --------
:: OS Version: %os_name_ver%
:: IP Address: %true_ip%
:: Province: %true_province%
:: City: %true_city%
:: ISP: %true_isp%
:: Date: %rq1% %rq2% %rq3%
:: Temperature: %wd1% %wd2% %wd3%
:: Weather: %tq1% %tq2% %tq3%
:: -------- End of variable comments --------
setlocal EnableDelayedExpansion
set a=┌───────────────────────────────────┐
set b=│ %os_name_ver% │
set c=├───────────────────────────────────┤
set d=│ %true_province%%true_city% Area 72-Hour Weather Forecast │
set e=├───────────┬───────────┬───────────┤
set f=│ %rq1% │ %rq2% │ %rq3% │
set g=├───────────┼───────────┼───────────┤
set h=│ %wd1% │ %wd1% │ %wd1% │
set i=├───────────┼───────────┼───────────┤
set j=│ %tq1% │ %tq2% │ %tq3% │
set k=└───────────┴───────────┴───────────┘
for %%i in (a b c d e f g h i j k) do (
set/p= <nul
for /l %%a in (0,1,100) do (
if not "!%%i:~%%a,1!"=="" (
if %%a==100 echo.&echo;
set/p=!%%i:~%%a,1!<nul
for /l %%i in (1,1,70) do ver>nul
)
)
echo.
)
endlocal
echo.
echo.
del %TEMP%\location.txt %TEMP%\cityInfo.txt %TEMP%\your_location.txt %TEMP%\source.txt %TEMP%\systeminfo.txt %TEMP%\eol.txt %TEMP%\Text.vbs %TEMP%\HTML.vbs >nul 2>nul
ping -n 6 >nul 2>nul
:: ━━━━━━━━━━━━━━━ Start of tail statement ━━━━━━━━━━━━━
setlocal DisableDelayedExpansion
set "P= Each segment of code has comments. For any shortcomings, please give more advice !!!"
set "K="
for /l %%j in (1,1,10) do (
set/p=%P%<nul
set/p=%K%<nul
for /l %%i in (1,1,250) do ver>nul
set/p= <nul
for /l %%i in (1,1,300) do ver>nul
set/p=%K%<nul
ping -n 1 127.1 >nul 2>nul
)
echo.
(Set,= http://kumho.lin.googlepages.com&For,/L,%%g,in,(0,1,85)Do,@Call,Set/P=%%,:~%%g,1%%<Nul&Ping/n 1 127.1>Nul)&Set,=&Ping -n 4 127.1>Nul
:: ━━━━━━━━━━━━━━━ End of tail statement ━━━━━━━━━━━━━
:: ------------------------- End of variable display layout code -----------------------
:quit
exit
:FullScreen
::Query display mode
Set ShowMode=0
for /f "delims=" %%i in ('REG QUERY HKEY_CURRENT_USER\Console /v "FullScreen"') do set ShowMode=%%i
Set ShowMode=%ShowMode:~-1%
::Set display mode to full screen
REG ADD HKEY_CURRENT_USER\Console /v FullScreen /t REG_DWORD /d 1 /f>nul
::Start current script in full screen
start "" %0 %ShowMode%
--------------------------------------------------------------------------------------------------
Update:
1. With the help of slore, the full-screen effect is realized
Defect:
The method of modifying the registry and then passing parameters to call the batch script itself seems not so smooth for my batch script. Some variables cannot be obtained. It is definitely not because of slow network speed, because I run the batch script in the default window size, and then press ALT+ENTER, which is also full screen, and can normally obtain the corresponding variables. These variables need to be obtained online.
The effect of running my updated code is as follows:
┌───────────────────────────────────┐
│ Microsoft Windows XP Professional 5.1.2600 Service Pack 2 │
├───────────────────────────────────┤
│ Guangdong Guangzhou Area 72-Hour Weather Forecast │
├───────────┬───────────┬───────────┤
│ │ │ │
├───────────┼───────────┼───────────┤
│ │ │ │
├───────────┼───────────┼───────────┤
│ │ │ │
└───────────┴───────────┴───────────┘
[ Last edited by dosmania on 2007-9-23 at 07:38 PM ]

