V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
xurunfei
V2EX  ›  macOS

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

  •  
  •   xurunfei · Aug 28, 2020 · 2282 views
    This topic created in 2080 days ago, the information mentioned may be changed or developed.

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

    6 replies    2020-08-28 16:00:27 +08:00
    Volekingsg
        1
    Volekingsg  
       Aug 28, 2020
    Hammerspoon 可以做到
    certainly
        2
    certainly  
       Aug 28, 2020 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
       Aug 28, 2020
    xurunfei
        4
    xurunfei  
    OP
       Aug 28, 2020
    @certainly 再问一下能获取到当前输入法是英文状态还是中文状态吗,我 mac 就用了搜狗,shift 切换状态,想直接检测当前是中文输入还是英文输入,根据不同 app 切换
    xurunfei
        6
    xurunfei  
    OP
       Aug 28, 2020
    @scukmh 这个我找到了,他是通过切换输入法的,我把 mac 自带的给去掉了,就用了搜狗,刚才找到了搜狗自己实现了这个功能,好像不用我去切换了😀
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2865 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 53ms · UTC 02:00 · PVG 10:00 · LAX 19:00 · JFK 22:00
    ♥ Do have faith in what you're doing.