标题: [其他] bat如何定时关闭 [打印本页]
作者: jjss520 时间: 2019-8-23 08:52 标题: bat如何定时关闭
个人需要循环点击手机音量键就百度加上自己修改了这个代码,代码可以循环的点击音量键
但现在定时关闭,比如设置半小时后自动关闭该批处理
请问各位大神,应该怎么加,菜鸟一个,论坛搜索也没得到答案
谢谢- @echo off
- :one
- ::adb shell input swipe 900 1000 700 1000
- adb shell input keyevent 25 %KEYCODE_VOLUME_DOWN%
- ping -n 6 127.0.0.1>nul
- goto two
-
- :two
- adb shell input keyevent 25 %KEYCODE_VOLUME_DOWN%
- ping -n 6 127.0.0.1>nul
- goto one
复制代码
作者: 窄口牛 时间: 2019-8-23 10:51
exit或者taskkill /im cmd.exe /f
作者: jjss520 时间: 2019-8-26 11:16
回复 2# 窄口牛
怎么定时半小时结束呢,请教
作者: jjss520 时间: 2019-8-26 11:21
@echo off
ne
::adb shell input swipe 900 1000 700 1000
adb shell input keyevent 25 %KEYCODE_VOLUME_DOWN%
ping -n 6 127.0.0.1>nul
goto two
:two
adb shell input keyevent 25 %KEYCODE_VOLUME_DOWN%
ping -n 6 127.0.0.1>nul
goto one
ping localhost -n 1800 > nul&taskkill /f /im cmd.exe
这样加在后面,这段命令不会运行
前面两段命令,一直在重复,怎么设这个半小时结束的命令生效呢
作者: flashercs 时间: 2019-8-26 14:21
- @echo off
- REM timelimit是半小时期限,单位是10ms
- set /a timelimit=180000
- call :getTod time_1
-
- :one
- ::adb shell input swipe 900 1000 700 1000
- adb shell input keyevent 25 %KEYCODE_VOLUME_DOWN%
- ping -n 6 127.0.0.1>nul
- goto two
-
- :two
- adb shell input keyevent 25 %KEYCODE_VOLUME_DOWN%
- ping -n 6 127.0.0.1>
- call :getTod time_2
- set /a "time_dist=time_2-time_1"
- if %time_dist% LSS 0 set /a "time_dist+=8640000"
- if %time_dist% lss %timelimit% (
- goto one
- )
- exit /b
- :getTod -- get a Time of Day value in 1/100th seconds
- :: -- %~1: out - time of day
- SETLOCAL
- set t=%time: =0%
- set /a t=((1%t:~0,2%*60+1%t:~3,2%)*60+1%t:~6,2%)*100+1%t:~9,2%-36610100
- ( ENDLOCAL & REM RETURN VALUES
- IF "%~1" NEQ "" SET %~1=%t%
- )
- GOTO:EOF
复制代码
作者: jjss520 时间: 2019-8-26 16:15
回复 5# flashercs
老大,代码好像不太对,打开过一会儿就关了
作者: flashercs 时间: 2019-8-26 16:57
回复 6# jjss520
第14行:改为ping -n 6 127.0.0.1>nul
作者: 窄口牛 时间: 2019-8-26 19:38
- @echo off
- echo @echo off>>%temp%\run.bat
- echo :1>>%temp%\run.bat
- echo adb shell input keyevent 25 %%KEYCODE_VOLUME_DOWN%%>>%temp%\run.bat
- echo ping -n 6 127.0.0.1^>nul>>%temp%\run.bat
- echo goto ^1>>%temp%\run.bat
- start "" %temp%\run.bat
- timeout /t 1800 /nobreak
- taskkill /f cmd.exe /im
复制代码
作者: h503mc 时间: 2019-8-28 17:35
- @echo off
- if "%1"=="deamon" goto deamon
- set TempFile=%TEMP%\sthUnique.tmp
- wmic process where (Name="wmic.exe" AND CommandLine LIKE "%%%TIME%%%") get ParentProcessId /value | find "ParentProcessId" >%TempFile%
- set /P _string=<%TempFile%
- set _pid=%_string:~16%
- echo %_pid% >pid.txt
- goto start
- :deamon
- @echo off
- set /p ppid=<pid.txt
- del pid.txt
- ping 127.1 /n 1801 >nul
- taskkill /f /pid %ppid%
- exit
- :start
- start /min "" %0 deamon
- :one
- ::adb shell input swipe 900 1000 700 1000
- adb shell input keyevent 25 %KEYCODE_VOLUME_DOWN%
- ping 127.1 /n 6 >nul
- goto two
-
- :two
- adb shell input keyevent 25 %KEYCODE_VOLUME_DOWN%
- ping 127.1 /n 6 >nul
- goto one
复制代码
已测试,先告知子程序pid,在杀进程.
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |