问题
I would like to disable the primary monitor on a Mac and then change secondary monitor to be the main programmatically. Any help on how I can do this? Not sure where to start my research.
回答1:
To change the secondary monitor to be the main screen is quite straightforward. One need to set the origin 0,0 to the secondary display using CGConfigureDisplayOrigin()
.
A full sample can be found Here
To the question how to disable the monitor, unfortunately I have no answer.I am trying to figure out how it can be done because there are some applications like SwitchResX
that are able to disable displays, so somehow it must be possible.
回答2:
hmscreens work great:
http://www.hamsoftengineering.com/codeSharing/hmscreens/hmscreens.html
Here's a sample command line to swap mointors:
hmscreens -setMainID `hmscreens -info | grep "Screen ID:" | head -2 | tail -1 | sed 's/[^0-9]*//g'`
来源:https://stackoverflow.com/questions/13722508/change-main-monitor-on-mac-programmatically