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

脚本有办法检测 macos 切换到哪个应用吗

  •  
  •   xurunfei · 2020-08-28 11:05:19 +08:00 · 1453 次点击
    这是一个创建于 1329 天前的主题,其中的信息可能已经有所发展或是发生改变。

    比如浏览器切换到微信,微信切换到开发工具,有没有办法检测到,用什么方法都行,最好是脚本检测

    6 条回复    2020-08-28 16:00:27 +08:00
    Volekingsg
        1
    Volekingsg  
       2020-08-28 13:15:17 +08:00
    Hammerspoon 可以做到
    certainly
        2
    certainly  
       2020-08-28 13:25:52 +08:00 via iPhone   ❤️ 1
    tell application "System Events" to set frontApp to name of first process whose frontmost is true

    if (frontApp = "Safari") or (frontApp = "Webkit") then
    xurunfei
        3
    xurunfei  
    OP
       2020-08-28 14:39:20 +08:00
    xurunfei
        4
    xurunfei  
    OP
       2020-08-28 15:05:47 +08:00
    @certainly 再问一下能获取到当前输入法是英文状态还是中文状态吗,我 mac 就用了搜狗,shift 切换状态,想直接检测当前是中文输入还是英文输入,根据不同 app 切换
    scukmh
        5
    scukmh  
       2020-08-28 15:23:10 +08:00
    xurunfei
        6
    xurunfei  
    OP
       2020-08-28 16:00:27 +08:00
    @scukmh 这个我找到了,他是通过切换输入法的,我把 mac 自带的给去掉了,就用了搜狗,刚才找到了搜狗自己实现了这个功能,好像不用我去切换了😀
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2893 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 00:29 · PVG 08:29 · LAX 17:29 · JFK 20:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.