Script that hides the dock

Discussion in 'Mac Programming' started by Photog, Sep 20, 2006.

  1. macrumors newbie

    Joined:
    Sep 20, 2006
    #1
    I am looking for any clue on how to write a script that would close the dock every 5-10 minutes. I am a beginner at the scripting world. I have multiple users on my machine and they tend to unhide the dock. It is possible to have a script running in the background to hide the dock every few minutes.

    Thanks in advance.
     
  2. macrumors 603

    MacBoobsPro

    Joined:
    Jan 10, 2006
    #2
    Does auto hide not do the job?
     
  3. thread starter macrumors newbie

    Joined:
    Sep 20, 2006
    #3
    It does but I would rather have it scripted so everytime I sit down I do not have to hide the dock. A simple script would hide it for me.
     
  4. macrumors 603

    MacBoobsPro

    Joined:
    Jan 10, 2006
    #4
    Oh i see :)

    I know its not a script but could you not put the sytem pref icon in your dock? That way you can change auto hide in 3 clicks. System Pref > Dock > Autohide. Just a suggestion, i dont know scripting so i cant help in that way.
     
  5. macrumors 68000

    Sharewaredemon

    Joined:
    May 31, 2004
    Location:
    Pitch forking mulch in Nova Scotia, Canada
    #5
    Well there is a hotkey to do it.

    Command Option D, I don't see why that's so hard to do...

    Am I confused about what you want to do?
     
  6. macrumors 603

    MacBoobsPro

    Joined:
    Jan 10, 2006
    #6
    ...Boom!
     
  7. macrumors 68000

    savar

    Joined:
    Jun 6, 2003
    Location:
    District of Columbia
    #7
    I don't think you can do it with a script -- but I'm not a scripter so I could be wrong.

    It's definitely possible using Cocoa. There are some undocumented APIs that I found to manipulate the dock. I'm sure others have found them too and explained them, try google.
     
  8. macrumors 65816

    Unorthodox

    Joined:
    Mar 3, 2006
    Location:
    Not at the beach...
    #8
    I tried to make a script to do so but I can't figure out how to select menu items within sub-menus.

    You could try remembering the shortcut "option command D"
    That toggles the dock hiding on and off.

    I can make a script that simulates that keystroke but then you just have a script that toggle the dock hiding.
     
  9. macrumors 6502

    Joined:
    Sep 15, 2006
    #9
    I believe you can kill the dock if you know the pid (?), but it might resurface / make the system less stable
     
  10. macrumors 65816

    Unorthodox

    Joined:
    Mar 3, 2006
    Location:
    Not at the beach...
    #10
    If you kill the dock it just starts up again.
     
  11. macrumors 6502

    Joined:
    Sep 15, 2006
    #11

    I just never seem interested in trying this kind of things, alas it was worth a shot :)
     
  12. macrumors 65816

    Unorthodox

    Joined:
    Mar 3, 2006
    Location:
    Not at the beach...
    #12
    Yay!
    I figured it out.
    Set the top variable (min_to_delay) to the amount of minutes you want to tick by before the it tries to hide the dock again.

    Copy past this into "Script Editor", save it as an application, give it a name, a location and fire it up.
    By default it will hide the dock every 10 minutes.

    The drawbacks are:
    -The only way to quit this script is to force quit it (command option esc)
    -It adds another icon to the dock

    Since you want to hide the dock the icon might not bother you.
    If it does you can disable it using this application.
    If you do choose to hide the dock icon the only way to quit this script will be to open "Activity Monitor", select the it's process name and force quit it.

     
  13. thread starter macrumors newbie

    Joined:
    Sep 20, 2006
    #13
    Thanks, here is the one someone at my work recently made for me.

     

Share This Page