PDA

View Full Version : Help Appreciated: Hide Dock (apple)script!




adom
Jun 21, 2006, 01:35 PM
Hey there. :)

OK, so I'm a complete scripting novice :confused: , more-so having moved to the mac platform about 6 months ago. What my question is, is whether or not it would be possible to make the Dock disappear when 'certain' applications are open.

I know you can turn Auto-Hide on all the time, but I dont like to hide the dock when im using my iMac on a general basis - but now that I have Aperture, I'de like Auto-Dock Hiding to turn on when that program is executed, and visa versa when I exit the app.

Is this at all possible? Ide like to be able to do it with Photoshop when I get it too, having a full screen for the app when its open, and auto revert back to showing the dock when they are not.

Any help, or scripts to do this would be VERY much appreciated.

Cheers, Adam :D



macattack5
Jun 21, 2006, 02:57 PM
yah i dont know much about it either, but can't you just use automater to do what you want?

adom
Jun 21, 2006, 03:08 PM
yah i dont know much about it either, but can't you just use automater to do what you want?

Ive tried and I cant see the option to hide the dock...and I also dont know how I would revert the action (thus turning Auto-Hiding off) when I close Aperture and the apps I want to do this to.

I hope someone knows...this has been bugging me for aages!

emw
Jun 21, 2006, 03:13 PM
If you hit Cmd-Option-D it will activate Dock hiding. You could simply press that before opening the applications.

HexMonkey
Jun 21, 2006, 03:24 PM
There's no clean way of doing this as there aren't any commands to directly change the Dock's status and you can't have a script triggered when an application opens/closes. However, this script might be of use:

property hideApps : {"Aperture", "Photoshop"} --Applications to hide the Dock in
property delayTime : 1 --Time between checks

set dockHidden to false
repeat
tell application "System Events"
--Get the frontmost process
set theProc to name of first process whose frontmost is true

--Check if the dock should be shown/hidden
if theProc is in hideApps and not dockHidden then
--Hide the Dock
keystroke "d" using [command down, option down]
set dockHidden to true
else if theProc is not in hideApps and dockHidden then
--Show the dock
keystroke "d" using [command down, option down]
set dockHidden to false
end if
end tell
delay delayTime
end repeat

The drawbacks:
The script must be always running to work. If you want to stop it you'll need to force quit it.
It can't detect whether the Dock is currently shown/hidden, only toggle it, so it assumes it's shown to begin with and that its status is never changed manually.


This script checks the active application rather than all open applications as I thought this would be more useful, but if you want the latter let me know and I can change it.

adom
Jun 21, 2006, 03:44 PM
If you hit Cmd-Option-D it will activate Dock hiding. You could simply press that before opening the applications.

Yea, i was just hoping the automation could be made.

Wow, Hex - thanks for your reply.

When I say im a novice, I mean I dont have a clue where to start in implementing the script(s). How would I go about setting up this script?

I know it may have flaws (i.e. if i opened Aperture, then PS the script would toggle incorrectly as if would assume the dock was opened)...but I'de love to try it.

Sorry for my novice ways, but Ide love how to learn!

Again thankyou! :D


P.S Thinking about it, I would only have either-or one of the apps open. Not both at once....hence the reason ide want the full screen

prostuff1
Jun 21, 2006, 05:55 PM
This is actually a really cool thing. Thanks for the work HexMonkey.

The only thing i was wondering is if there was a way to hide the dock icon so that it is not in the dock. Kinda like some applications can be hidden (example quicksilver)

If that could be done to this script taht would be great.

and adom:

Open Script Editor and paste the stuff in the code box into the window. Then go to file>Save as. Select the file format as application. Give it a name and then hit the save button. Once that is done just double click it to start it running.

Hope that helps.

HexMonkey
Jun 21, 2006, 09:06 PM
I know it may have flaws (i.e. if i opened Aperture, then PS the script would toggle incorrectly as if would assume the dock was opened)...but I'de love to try it.

Actually it will work correctly with both open at once. It just assumes the Dock is shown when it first launches, after that it keeps an internal record which should remain accurate as long as the setting isn't changed manually.

See prostuff1's post for instructions on using the script.

The only thing i was wondering is if there was a way to hide the dock icon so that it is not in the dock. Kinda like some applications can be hidden (example quicksilver)

As far as I know there's no easy way of doing this in AppleScript. Most applications are bundles and can be made to run in the background by modifying the Info.plist file inside them; however AppleScript applications are not, so this can't be done.

adom
Jun 22, 2006, 09:26 AM
Actually it will work correctly with both open at once. It just assumes the Dock is shown when it first launches, after that it keeps an internal record which should remain accurate as long as the setting isn't changed manually.

See prostuff1's post for instructions on using the script.



As far as I know there's no easy way of doing this in AppleScript. Most applications are bundles and can be made to run in the background by modifying the Info.plist file inside them; however AppleScript applications are not, so this can't be done.


Cool thanks guys. will try when im at home.

wmmk
Jun 22, 2006, 10:10 AM
Quote:
Originally Posted by prostuff1
The only thing i was wondering is if there was a way to hide the dock icon so that it is not in the dock. Kinda like some applications can be hidden (example quicksilver)

As far as I know there's no easy way of doing this in AppleScript. Most applications are bundles and can be made to run in the background by modifying the Info.plist file inside them; however AppleScript applications are not, so this can't be done.
ow do i do this for norml "bundle" applications? in particular MAMP and no-ip dns updater?

HexMonkey
Jun 22, 2006, 04:31 PM
ow do i do this for norml "bundle" applications? in particular MAMP and no-ip dns updater?

Add the following to the Info.plist file inside the bundle (you should make a copy first). Add it so as to keep the keys sorted alphabetically (it will probably end up just before NSMainNibFile).
<key>LSUIElement</key>
<integer>1</integer>

If you have the Developer Tools installed, use Property List Editor instead.

Note that you might run into problems with this if the application wasn't designed for it, eg you won't be able to access the program's menus.