Applescript以全屏模式打开应用程序?

时间:2016-03-28 22:34:31

标签: macos shell applescript alfred

我正在尝试使用工作流程编程Alfred打开我的终端,Sublime Text和Chrome。

我希望我的终端能够正常打开窗口,但我一直在努力让Chrome和Sublime全屏开启。

我可以通过以下方式让Chrome以全屏模式打开:

on alfred_script(q)
   tell application "Google Chrome"
        tell window 1 to enter presentation mode
   end tell
end alfred_script

然而,这并没有转化为我的Sublime Text。

我在这里缺少什么?

2 个答案:

答案 0 :(得分:1)

在此处找到(i need an applescript to open safari in full screen an to hide the toolbar on mavericks

tell application "Safari"

    activate

    delay 3

    tell application "System Events" to tell process "Safari"

        set value of attribute "AXFullScreen" of window 1 to true

    end tell

end tell

答案 1 :(得分:1)

另一种方法是假设您没有更改“输入全屏”的默认键盘快捷键,只需让系统事件调用该快捷方式(^⌘F)即可。与我见过的其他方法一样(更改AXFullScreen的值 - 请参阅mklement0's answer here以深入讨论此方法),这需要激活相关窗口。

例如,要在Safari中切换最前面窗口的全屏状态,请运行:

tell application "Safari" to activate
tell application "System Events"
        keystroke "f" using {command down, control down}
end tell
相关问题