Using AppleScript (or Python PyObjC) to list out all applications in the Dock on Mac (All parts)

26 Views Asked by At

Context: Often when I use Visual Studio Code, I open up multiple instances of the program. I eventually end up closing them and then I am left with multiple closed VS Codes in my Dock. I separate the Dock into 3 sections. The left is the persistent apps, the right is the bin and minimised (but open) apps. Between the left and right are the middle apps which either do not have a spot amongst the persistent apps but are open. When these apps are closed then the icon still lives in the middle but the small, gray circle (signifying the app is open) is not longer present. Therefore, the app is closed. I find myself sitting manually "Removing from Dock" often to get rid of these apps.

I have found multiple questions and solutions on how to list out the applications living in the persistent part of the Dock. However, these solutions do not list all applications.

Question: How can I use Python, AppleScript, or bash to list out all of the applications (across all 3 sections)?

I have tried exploring AppleScript and have used solutions like this to find the applications in the Dock. I have also used AppKit and PyObjC (a Python library) but have not been able to find a solution.

0

There are 0 best solutions below