shell 用Applescript在全屏模式下打开应用程序?

cyvaqqii  于 2023-08-07  发布在  Shell
关注(0)|答案(2)|浏览(174)

我正在尝试为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

字符串
然而,这并没有翻译成与我的崇高文本。
我错过了什么?

kcrjzv8t

kcrjzv8t1#

另一种方法是假设你没有改变默认的键盘快捷键“进入全屏”,简单地让系统事件调用该快捷键(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

字符串

frebpwbc

frebpwbc2#

在这里找到(i need an applescript to open safari in full screen an to hide the toolbar on mavericks)。make new document行通过打开一个新选项卡(如果以前没有打开过)来防止can't get window 1错误。

tell application "Safari"

    make new document
    
    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

字符串

相关问题