简体   繁体   中英

Programmatically move Mac menu bar between displays

I'm looking for a way to programmatically move the menu bar on a multi-display setup from one display to another. Ideally I would do this in Objective C, but I'm open to shell scripts, AppleScript, etc.

In Objective C, I can get a pointer to the screen with the menu bar by using [[NSScreen screens] objectAtIndex: 0] . However, I obviously cannot write to that array.

Is there an NSUserDefaults preference I can switch? I ran defaults read > defaults.txt in Terminal to try to find the correct one, but it's like finding a needle in a haystack :)

You can use a command line tool I created to do that here . You'll also find the source code to the tool on the web page so you can see how I did it programmatically and use that as an example for your code. Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM