Open an application in a space using applescripts

让人想犯罪 __ 提交于 2019-12-24 04:47:22

问题


I am trying to create a script that will open an application in a specific "space". So let's say I am on space 1 working in the terminal and then I want to be able to open safari in space 4. Is there a way to do this?

I have done some searching and found only ways to set the system profile options. Maybe I should tell you my end goal in case what I am attempting is not possible.

I use a laptop and plugin in to multiple stations, home, office, and travel. I want to create different window layouts for each one. So I will need an apple script telling it to open applications in varios spaces and different dimensions. I hope this makes sense. Ask me for clarification if it doesn't thanks!

PS the answer doesn't necessarily have to be any applescript I just thought that would be the easiest way :)


回答1:


It is possible to do some scripting of application Space preferences by using the scripting interface to the System Events.app. See the answer to a similar question here.




回答2:


Here's a list of applescript commands for Spaces. There's a couple things there that might help you.




回答3:


The easiest way I've found is via GUI scripting. Make sure the Spaces menu is active on the upper right of your computer. That lists the spaces by number. You can then just write a GUI script to select the menu item of the space you wish. That will switch to that space. Then do an activate Applescript to open the application there.

Let me know if you need sample code demonstrating this. I have some in Python + Appsscript that does this but I should be easily able to convert it back to Applescript proper if you need it.



来源:https://stackoverflow.com/questions/5691362/open-an-application-in-a-space-using-applescripts

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