How to input ampersand with adb shell input?

2019-06-24 05:05发布

问题:

adb shell input text "&" doesn't work, nor does adb shell input keyevent KEYCODE_AMPERSAND.

Related to question 7789826.

回答1:

Try:

adb shell input text "\&"


回答2:

For anyone stumbling across this in the future, the escape that finally worked from me was not \&, but rather "\&"

as in

adb shell echo Macaroni "\&" Cheese

and not

adb shell echo Macaroni \& Cheese

Hopefully this helps someone.

For the record, this is on Windows.