6

我正在尝试让 OS X Lion 中的停靠栏和菜单栏在全球范围内自动隐藏。我希望它对所有程序都这样做的原因是因为我正在尝试在 wine 中玩游戏,并且在全屏运行时 CPU 使用率会飙升,所以在玩窗口时我总是不得不手动告诉停靠在播放前隐藏。

我知道编辑 info.plist 和 LSUIPresentationMode 键,但不幸的是游戏启动器注意到该文件已被编辑并在启动前修复它。所以我唯一的选择是在开始之前让它对所有程序隐藏,这可能吗?AppleScript 甚至是解决此问题的最佳方法吗?我对在 Mac 上进行编码仍然很陌生,因此对如何完成此操作的任何建议表示赞赏。

4

4 回答 4

7

你可以很容易地做码头。我不知道如何全局做菜单栏。我怀疑这是可能的。这是码头的脚本。它将根据当前情况将其切换为自动隐藏或不自动隐藏。祝你好运。

tell application "System Events"
    tell dock preferences to set autohide to not autohide
end tell
于 2013-01-21T15:41:20.687 回答
6

对于那些仍然感兴趣的人,这对于那些使用 OS X 的人来说是一个解决方案。“常规设置”页面现在从tab不起作用的搜索栏开始。这是一个解决方法。

tell application "System Preferences"

    --open General Settings
    activate
    set the current pane to pane id "com.apple.preference.general"
    try

        --wait for screen to boot
        repeat until window "General" exists
            delay 0.2
        end repeat
        delay 0.5
    on error error_message
        get error_message
    end try
end tell


--click the appropriate check box
tell application "System Events"
    click checkbox "Automatically hide and show the menu bar" of window "General" of application process "System Preferences" of application "System Events"
end tell
于 2017-03-02T03:58:13.270 回答
4

对于大苏尔:

tell application "System Events"
    tell dock preferences to set autohide menu bar to not autohide menu bar
end tell
于 2020-12-19T03:06:47.100 回答
0

这是一个为我做的applescript,因为它也是我真正想看到的东西。我不确定它是否会赢得风格点,但我使用 Automator 服务调用它并为其设置键盘快捷键,从那以后我没有抱怨过它。

tell application "System Events"
    tell dock preferences
        --get the properties list of the dock and set (or assign) it to our variable we'll call "dockprops"
        set dockprops to get properties
        --in our now "dockprops" list, assign our target dock property ("autohide") to the variable "dockhidestate"
        set dockhidestate to autohide of dockprops
        --the dock's "autohide" property is a boolean: it's value can only be either true or false
        --an "if statement" provides the necessary logic to correctly handle either of these cases in this one single script
        if autohide = true then
            tell application "System Events"
                tell dock preferences to set autohide to not autohide
            end tell
        else
            set autohide to true
        end if
    end tell
end tell

tell application "System Preferences"

    activate
    --  tell application "Finder" to tell process "System Preferences" to set visible to false
    set the current pane to pane id "com.apple.preference.general"

    --  The delays are necessary as far as I can tell
    delay 0.5
    tell application "System Events" to keystroke tab
    delay 0.5
    tell application "System Events" to keystroke tab
    tell application "System Events" to keystroke tab
    tell application "System Events" to keystroke space
    tell application "System Events" to key code 13 using {command down}
end tell
于 2016-09-01T04:24:51.907 回答