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

Mac 上如何通过脚本来在焦点输入框内输入一段文字?

  •  
  •   TheCure · 2017-09-09 01:09:38 +08:00 · 2868 次点击
    这是一个创建于 2393 天前的主题,其中的信息可能已经有所发展或是发生改变。

    类似 yubikey 我跑一个脚本或者快捷键触发一个动作, 就会在当前焦点输入一串密码.

    6 条回复    2020-09-25 20:07:46 +08:00
    xiaket
        1
    xiaket  
       2017-09-09 06:13:34 +08:00 via iPhone
    我用 AppleScript 来唤起 app 里面的输入框,供我输入内容并保存生效。但我不确定它本身是否有获取 focus 的特性(可能有)
    minamike
        2
    minamike  
       2017-09-09 06:51:47 +08:00 via iPhone
    keyboard maestro 可以
    jedihy
        3
    jedihy  
       2017-09-09 07:19:37 +08:00 via iPhone
    强烈推荐 hammerspoon,自己写两行 lua 就搞定了
    ashfinal
        4
    ashfinal  
       2017-09-09 14:57:59 +08:00
    按下 "opt+v",输入 markdown 格式的当前网址:

    [Mac 上如何通过脚本来在焦点输入框内输入一段文字? - V2EX]( https://www.v2ex.com/t/389330#reply3)

    用的 hammerspoon。repo 在这里: https://github.com/ashfinal/awesome-hammerspoon
    pbjacob
        5
    pbjacob  
       2017-09-13 13:06:41 +08:00
    automator 建一个 service,输入选 no,应用程序选 any
    拖一个 run applescript 进来,自定义代码段里写:

    tell application "System Events"
    keystroke "This is the password for test"
    end tell

    去系统设置键盘快捷键里给它配一个 shortcut,就搞定了。
    madao100
        6
    madao100  
       2020-09-25 20:07:46 +08:00
    @pbjacob 谢谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2901 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 13:58 · PVG 21:58 · LAX 06:58 · JFK 09:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.