V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
ri0day
V2EX  ›  macOS

请教一段关于用applescript 自动登录qq的脚本

  •  
  •   ri0day · 2014-01-05 21:32:26 +08:00 · 4586 次点击
    这是一个创建于 3763 天前的主题,其中的信息可能已经有所发展或是发生改变。
    自从新买的mac到了以后,最近都在熟悉mac os x ,发现applescript 很强大。于是网上看了一些例子,写了一个自动登录qq的脚本,但是发现输入密码的时候 按键输入到了错误的窗口中。
    请大家看看什么问题

    tell application "QQ"
    activate

    tell application "System Events"
    tell application process "QQ"
    keystroke "password"
    keystroke return
    end tell
    end tell
    end tell
    1 条回复    1970-01-01 08:00:00 +08:00
    ri0day
        1
    ri0day  
    OP
       2014-01-06 21:40:32 +08:00   ❤️ 1
    解决了:一定要把QQ这个应用设置到frontmost ,也就是focus到当前的app 窗口上

    tell application "QQ" to activate
    tell application "System Events" to set frontmost of process "QQ" to true
    tell application "System Events"
    keystroke "password"
    keystroke return
    end tell
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4163 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 05:30 · PVG 13:30 · LAX 22:30 · JFK 01:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.