如果我选择变量2,批处理文件将继续关闭

时间:2019-02-10 01:13:56

标签: batch-file adb

我目前正在批量制作自己的ADB工具包菜单 因此我继续测试了批处理文件,但是如果我选择变量2,它总是会退出批处理文件。

from turtle import Screen, Turtle  # unlearn nifty * trick

WIDTH, HEIGHT = 1000, 600

ROOT = 3 ** 0.5

size = float(input("How large would you like the hexagons to be? (5-50): "))

screen = Screen()
screen.setup(WIDTH, HEIGHT)
screen.bgcolor('gray')

turtle = Turtle(visible=False)
turtle.fillcolor('red')
turtle.penup()

left_edge = size/2 - WIDTH/2
x, y = left_edge, HEIGHT/2 - size * ROOT

screen.tracer(False)  # because I have no patience

for row in range(int(HEIGHT // (size * ROOT)) + 1):
    turtle.goto(x, y)
    turtle.begin_fill()

    for column in range(int(WIDTH // (size * 2)) + 1):
        turtle.pendown()

        for _ in range(6):
            turtle.forward(size)
            turtle.left(60)

        turtle.penup()
        turtle.forward(size * 2)

    turtle.end_fill()

    x = left_edge
    y -= size * ROOT

screen.tracer(True)
screen.exitonclick()

1 个答案:

答案 0 :(得分:1)

对于该任务,我建议使用以下较短的代码:

@echo off

:menu
cls

title ADB TOOLKIT
echo.
echo.
echo   ----------------------------
echo   ADB TOOLKIT MADE BY TECHDARK
echo   ----------------------------
echo.
echo.
echo ---------------
echo 1) Install APK
echo 2) Unlock phone
echo 3) Lock phone
echo ---------------

choice /c:123 /M "Type 1, 2 or 3: " /N
cls

if errorlevel 3 goto lock
if errorlevel 2 goto unlock
if errorlevel 1 goto install

:install
echo What do you want to install?
set /p "install=Type in apk: "
cls
echo Installing...
echo.
adb install "apps\%install%"
pause
goto menu

:lock
adb shell input keyevent 26
cls
echo Your phone is locked!
pause
goto menu

:unlock
choice /C:yn /M "Does your phone have a password or PIN? "

if errorlevel 2 goto nopswdunlock
if errorlevel 1 goto pswdunlock

pause

:nopswdunlock
cls
adb shell input keyevent 26
cls
echo Your phone is locked!
pause
goto menu

:pswdunlock
cls
set /p "PIN=What is your PIN/Password? Type here: "
cls
echo Unlocking, please wait...
echo.
adb shell input keyevent 26 && adb shell input keyevent 1 && adb shell input text %PIN% && adb shell input keyevent 66
pause
goto menu

有关此处使用的命令功能的信息,请参见choice /?set /?