Change main monitor on Mac programmatically

有些话、适合烂在心里 提交于 2019-12-11 02:05:56

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!