V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
mfyhx1417
V2EX  ›  Python

请问, adb 输入内容和手动点击键盘输入的区别在哪?

  •  
  •   mfyhx1417 · Jun 22, 2024 · 2891 views
    This topic created in 687 days ago, the information mentioned may be changed or developed.

    如题,登陆某 app 需要输入密码

    手动在键盘输入密码,假设密码是:"Abc@123",能登陆成功

    但是通过 adb 输入相同密码(输入的密码确认是一样的),却提示密码错误

    adb shell input text Abc@123
    

    尝试使用 python appium ,一个一个字符输入也提示密码错误

    def input_keycode(self, text):
        for i in text:
            time.sleep(0.5)
            if i == '@':
                self.driver.press_keycode(77)
            elif i.isnumeric():
                keycode = int(i) + 7
                self.driver.press_keycode(keycode)
            else:
                if i.isupper():
                    keycode = ord(i.lower()) - ord('a') + 29
                    self.driver.press_keycode(keycode, 1)
                else:
                    keycode = ord(i) - ord('a') + 29
                    self.driver.press_keycode(keycode)
    

    难道安卓能检测到输入方式? 不太懂,求大佬们解答🙏

    6 replies    2024-06-24 15:07:42 +08:00
    alphaControler
        1
    alphaControler  
       Jun 22, 2024 via Android
    keycode 对应的字符不是你想的那样
    beixiao
        2
    beixiao  
       Jun 22, 2024 via Android
    用 uiautomator2 试试,最近也遇到一个输入框必须要用 adb 输入才行😂
    darkengine
        3
    darkengine  
       Jun 22, 2024
    可以写个 demo 试试,拖个 EditText 用 adb shell input 输入,用 logcat 打出来看是不是变了
    drymonfidelia
        4
    drymonfidelia  
       Jun 23, 2024
    好像不是 keycode 的问题,印象里确实有办法检测 keyup 的来源,好多年没做 android 开发了
    mfyhx1417
        5
    mfyhx1417  
    OP
       Jun 24, 2024
    @alphaControler 是一样的
    mfyhx1417
        6
    mfyhx1417  
    OP
       Jun 24, 2024
    好像知道问题了,应该是安卓那边使用了自定义键盘。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   973 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 22:48 · PVG 06:48 · LAX 15:48 · JFK 18:48
    ♥ Do have faith in what you're doing.