Investigate the Accessibility APIs for interacting and manipulating windows owned by other applications.
Info.plist value LSUIElement for making an agent application:
LSUIElement (Boolean - macOS) specifies whether the app runs as an agent app. If this key is set to YES, Launch Services runs the app as an agent app. Agent apps do not appear in the Dock or in the Force Quit window. Although they typically run as background apps, they can come to the foreground to present a user interface if desired. A click on a window belonging to an agent app brings that app forward to handle events.
The Dock and loginwindow are two apps that run as agent apps.
To be distributed on Apple's Mac App Store, an application must have a user interface. This can be a simple window that enables your service, or handles preferences.
Search GitHub for status menu app for open source examples.