Is the dock a window, a location...?
I want something to be executed only when the dock is visible. With a picture of the Finder icon it works. Should I leave it like this or is there a better solution?
Probably.
Is the dock a window, a location...?
I want something to be executed only when the dock is visible. With a picture of the Finder icon it works. Should I leave it like this or is there a better solution?
Probably.
Hey Frank,
Iām thinking that later versions of macOS than what I have (Mojave) have access to the Dock's visible property.
Something like this:
tell application "System Events"
tell dock preferences
dock visible
end tell
end tell
You'll have to look at System Events' AppleScript dictionary in Apple's Script Editor.app or preferably Script Debugger. (Keep in mind that the commercial version reverts to a freeware "lite" version after a demo period, and the lite version still demolishes Apple's SE.)
This does work on my system:
tell application "System Events"
tell application process "Dock"
tell list 1
set dockPosition to its position
set dockYPosition to item 2 of dockPosition
return dockYPosition
end tell
end tell
end tell
dockYPosition
changes when the Dock's visibility changes.
-Chris
Ok, thanks Chris.
I will try that. Can you tell me why you would do it this way instead of with the picture? Just so I understand the difference
Well, it depends a bit upon what you're doing in your macro ā but in general running a script will take fewer resources than finding an image.
Finding an image is also dependent upon dark and light themes and screen resolution, so it's a little more likely to fail if/when you change things on your system.
Can confirm this is possible on Bug Sur and Monterey. I have some scripts to determine if the dock and menu bar are visible as well as get their dimensions and locations.