Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Sep 20, 2006, 08:47 AM   #1
Photog
macrumors newbie
 
Join Date: Sep 2006
Script that hides the dock

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.
Photog is offline   0 Reply With Quote
Old Sep 20, 2006, 08:52 AM   #2
MacBoobsPro
macrumors 603
 
MacBoobsPro's Avatar
 
Join Date: Jan 2006
Send a message via AIM to MacBoobsPro
Quote:
Originally Posted by Photog
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?
MacBoobsPro is offline   0 Reply With Quote
Old Sep 20, 2006, 08:55 AM   #3
Photog
Thread Starter
macrumors newbie
 
Join Date: Sep 2006
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.
Photog is offline   0 Reply With Quote
Old Sep 20, 2006, 09:07 AM   #4
MacBoobsPro
macrumors 603
 
MacBoobsPro's Avatar
 
Join Date: Jan 2006
Send a message via AIM to MacBoobsPro
Quote:
Originally Posted by Photog
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 is offline   0 Reply With Quote
Old Sep 20, 2006, 09:53 AM   #5
Sharewaredemon
macrumors 68000
 
Sharewaredemon's Avatar
 
Join Date: May 2004
Location: Pitch forking mulch in Nova Scotia, Canada
Send a message via MSN to Sharewaredemon
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?
__________________
Meow.
Sharewaredemon is offline   0 Reply With Quote
Old Sep 20, 2006, 10:01 AM   #6
MacBoobsPro
macrumors 603
 
MacBoobsPro's Avatar
 
Join Date: Jan 2006
Send a message via AIM to MacBoobsPro
Quote:
Originally Posted by Sharewaredemon
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!
MacBoobsPro is offline   0 Reply With Quote
Old Sep 20, 2006, 10:34 AM   #7
savar
macrumors 68000
 
savar's Avatar
 
Join Date: Jun 2003
Location: District of Columbia
Send a message via AIM to savar
Quote:
Originally Posted by Photog
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.
__________________
Mehce
savar is offline   0 Reply With Quote
Old Sep 20, 2006, 10:43 AM   #8
Unorthodox
macrumors 65816
 
Unorthodox's Avatar
 
Join Date: Mar 2006
Location: 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.
__________________
Advertise your site, software, or service in this space and be seen over 100,000ish times per day by your target audience. Click here for info.
Unorthodox is offline   0 Reply With Quote
Old Sep 20, 2006, 11:04 AM   #9
mufflon
macrumors 6502
 
Join Date: Sep 2006
I believe you can kill the dock if you know the pid (?), but it might resurface / make the system less stable
mufflon is offline   0 Reply With Quote
Old Sep 20, 2006, 11:23 AM   #10
Unorthodox
macrumors 65816
 
Unorthodox's Avatar
 
Join Date: Mar 2006
Location: Not at the beach...
Quote:
Originally Posted by mufflon
I believe you can kill the dock if you know the pid (?), but it might resurface / make the system less stable
If you kill the dock it just starts up again.
__________________
Advertise your site, software, or service in this space and be seen over 100,000ish times per day by your target audience. Click here for info.
Unorthodox is offline   0 Reply With Quote
Old Sep 20, 2006, 12:59 PM   #11
mufflon
macrumors 6502
 
Join Date: Sep 2006
Quote:
Originally Posted by Unorthodox
If you kill the dock it just starts up again.

I just never seem interested in trying this kind of things, alas it was worth a shot
mufflon is offline   0 Reply With Quote
Old Sep 20, 2006, 03:43 PM   #12
Unorthodox
macrumors 65816
 
Unorthodox's Avatar
 
Join Date: Mar 2006
Location: 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.

Quote:
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
__________________
Advertise your site, software, or service in this space and be seen over 100,000ish times per day by your target audience. Click here for info.
Unorthodox is offline   0 Reply With Quote
Old Sep 27, 2006, 08:52 AM   #13
Photog
Thread Starter
macrumors newbie
 
Join Date: Sep 2006
Thanks, here is the one someone at my work recently made for me.

Quote:
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
Photog is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Dock hides when I try to click on it islandcase OS X 10.8 Mountain Lion 0 Jan 17, 2014 04:05 PM
how to make the dock to wait 2-3 seconds before it hides. 1cosmonut MacBook Air 1 Dec 18, 2013 06:21 AM
Apple script batch shell script prramesh Mac Programming 5 Sep 15, 2013 04:35 AM
Dock auto-hides, although configured not to mzayats OS X 10.8 Mountain Lion 1 Oct 17, 2012 03:55 PM
first script/autamator script feed back zyr123 Mac Programming 1 Jul 17, 2012 11:00 AM

Forum Jump

All times are GMT -5. The time now is 04:07 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC