隐藏菜单栏并使用applescript全局停靠

时间:2013-01-21 06:45:36

标签: macos osx-lion applescript

我正在尝试让OS X Lion中的Dock和菜单栏全局自动隐藏。我希望它能为所有程序这样做的原因是因为我正在尝试用葡萄酒玩游戏,并且当全屏运行时CPU使用率会通过屋顶,所以在播放窗口时我总是不得不手动告诉在玩之前停靠。

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

4 个答案:

答案 0 :(得分:6)

您可以轻松地进行停靠。我不知道如何全局菜单栏。我怀疑这是可能的。这是Dock的脚本。它会根据当前条件将其切换为自动隐藏或不自动隐藏。祝你好运。

tell application "System Events"
    tell dock preferences to set autohide to not autohide
end tell

答案 1 :(得分:4)

大苏尔:

tell application "System Events"
    tell dock preferences to set autohide menu bar to not autohide menu bar
end tell

答案 2 :(得分:2)

对于那些仍然感兴趣的人,这是针对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

答案 3 :(得分:0)

这是一个为我做的苹果,因为它也是我真正想要看的东西。我不确定它会赢得风格点,但是我用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