How do I get the position, width, and height of a Mac OS X dock? Cocoa / Carbon / C ++ / Qt

I am trying to get the position and width of a Mac OS X dock in my C ++ / Qt application. But I can find ways to get the available desktop space, which means that I can get the height of the dock, but not the width.

Are there any ways to get the position and width of the dock using my own API?

+5
source share
2 answers

It doesn't seem like such a thing is possible, not even from Apple's APIs, much less from Qt.

The only solution that comes to mind is pretty rude is to take a screen shot and use some basic image recognition to find the position and size of the dock.

0
source

This can help in a solution without hacking, NSScreen provides a method ( visibleframe ) that subtracts the menu and the dock from the screen size. The frame method contains both.

[NSStatusBar system​Status​Bar].thickness will return the height of the menu bar.

https://developer.apple.com/reference/appkit/nsscreen/1388369-visibleframe?language=objc

+2
source

Source: https://habr.com/ru/post/1244516/


All Articles