hide menu bar and dock globally with applescript

You can do the dock easily. I do not know how to do the menu bar globally. I doubt it's possible. Here's a script for the dock. It will toggle it to auto-hide or not based on the current condition. Good luck.

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

For those still interested, this is a solution for those on OS X. The General Settings page now starts at the search bar where tab doesn't work. This is a work around.

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