Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Photog

macrumors newbie
Original poster
Sep 20, 2006
4
0
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.
 

MacBoobsPro

macrumors 603
Jan 10, 2006
5,114
6
Photog said:
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.

Does auto hide not do the job?
 

Photog

macrumors newbie
Original poster
Sep 20, 2006
4
0
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.
 

MacBoobsPro

macrumors 603
Jan 10, 2006
5,114
6
Photog said:
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.

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.
 

MacBoobsPro

macrumors 603
Jan 10, 2006
5,114
6
Sharewaredemon said:
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?

...Boom!
 

savar

macrumors 68000
Jun 6, 2003
1,950
0
District of Columbia
Photog said:
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.

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.
 

Unorthodox

macrumors 65816
Mar 3, 2006
1,087
1
Not at the beach...
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.
 

mufflon

macrumors 6502
Sep 15, 2006
264
2
I believe you can kill the dock if you know the pid (?), but it might resurface / make the system less stable
 

Unorthodox

macrumors 65816
Mar 3, 2006
1,087
1
Not at the beach...
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.

set min_to_delay to "10" --set this to how many minutes you want to go by before hiding the dock

set sec_to_delay to min_to_delay * 60
repeat
tell application "Finder"
activate
end tell
tell application "System Events"
if UI elements enabled then
try
click menu item "Turn Hiding On" of menu "Dock" of menu item "Dock" of menu "Apple" of menu bar 1 of process "Finder"
end try
delay sec_to_delay
else
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\" to use this script"
end tell
end if
end tell
end repeat
 

Photog

macrumors newbie
Original poster
Sep 20, 2006
4
0
Thanks, here is the one someone at my work recently made for me.

on idle

tell application "System Events" to tell process "Finder" to tell menu bar 1 to tell menu "Apple" to tell menu item "Dock" to tell menu 1 to get name of menu item 1
-- return result
if result is "Turn Hiding On" then
tell application "System Events" to keystroke "d" using {command down, option down}
else
-- quit me
end if

end idle
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.