2017-02-17 110 views
0

其Windows如何使用AppleScript的创建键盘快捷键这将应用程序和周期:启动/提高通过使用AppleScript和键盘快捷键

  • 启动应用软件,如果它没有运行。
  • 如果应用程序正在运行,则将应用程序置于前台。
  • 循环通过只有应用程序的窗口,如果我一直按快捷键。

例如,当我按下Option-Y,将推出终端或将其带到前台,如果我继续按Option-Y也将通过多个打开终端窗口周期,如果我有一个以上的打开。

我已成功创建一个AppleScript作为服务使用Automator。我已成功将此脚本映射到键盘快捷方式,方法是转到“系统首选项”,“键盘”,“快捷方式”,“服务”,然后在“常规”下,检查并分配键盘快捷方式到Automator服务BringTerminalToTheForeground。

这里是启动终端脚本:

tell application "Terminal" 
    activate 
end tell 

我想只有在默认情况下(例如的AppleScript,Automator的)来与Mac的工具来做到这一点。我正在运行El Capitan。

回答

0

命令 - “`”将在应用程序的窗口中循环。

tell application "Terminal" -- try other applications. This script might work in other cases. It happens to work with Terminal but I haven't tested it. 
    activate 
    set c to count of windows -- we need to know how many windows the application has so we only cycle through all of them once. 
    tell application "System Events" 
     repeat c times 
      keystroke "`" using command down -- this is what cycles through the windows. This doesn't work in every application. 
      delay 1 -- this is a 1-second delay. Change this to whatever delay you want. 
     end repeat 
    end tell 
end tell