Is the dock here ? / Dock size

I want to set a window as low as possible on the screen.

But that depends if the dock is visible or not.

With no dock, it would be

mywindow.top = Screen(0).Height-mywindow.height

Adn the window sets nicely at the very bottom edge of the screen.

With the dock, and admitting the dock height remains the same through different screen sizes (which I am not sure at this moment), it would be something like :

mywindow.top = Screen(0).Height-66-mywindow.height

Now, is there a way to know by code if the dock is displayed, and possibly its actual height ?

At this moment, I was thinking about capturing the screen image and checking the color of pixels where the dock appears as grey. But in Mavericks the reflects make the grey a changing color. That is one for Yosemite, where the flat look makes it easier. Somehow I hope there is a simpler way.

Thanks in advance for any hint.

Screen.AvailableHeight gives you the height without menu bar and dock

You can get all the Dock’s preferences with Applescript, including it’s position and tile height.
But it does not have a visible property in Mavericks, only an autohide property.

I’m sure it used to have a visible preference in earlier OSX versions, not sure when they removed that System Preference.

Regards Mark

Thank you both. Between the properties and AppleScript, I have all I need :slight_smile:

It appears I did not exactly have all I needed : to get the dock properties in AppleScript I need to call System Events, a definite no-no in an App Store app :frowning:

My concern is that I want to be able to know if I can place a small window in the lower left corner of the screen. If the dock is too wide, or too high (when placed sideways) there is no room, so the window must be placed on top, or on the right side, respectively.

I thought I had found a way to scan the screen to detect the doc but after experimenting it appears to be a bit more complex. I am on it though, and will post the solution when I got it.

Apple iron rule about sandbox and AppleScript is just like the rules of Formula 1 racing : every time rules are tightened, it is a challenge to engineers imagination.

I have found a way to locate the dock on the screen within a sandboxed app. I post it here in case someone else was confronted to the same necessity :

  • Create a 4 x 4 picture with a specific pattern that can be recognized by the program and is used as backdrop to a 4 x 4 plain box window
  • Display the 4x4 window at the location where I want to make sure the screen is clear
  • Capture the screen into the clipboard
  • Place the 4x4 area where the window has been shown into a picture with Drawstring
  • Convert the original picture to string through a MemoryBlock
  • Convert the captured picture to string through a MemoryBlock
  • Compare the two strings ; if identical, it means the screen is clear at the window location. If not identical, it means the window was covered by the dock.

Now all I got to do is to check the dock is not covering the right or top edge of the small window I want to place on the lower left corner of the screen. If it does, then I will show my small window above or on the right.