【问题标题】:Applescript; opening an app in Space number N苹果脚本;在空间编号 N 中打开应用程序
【发布时间】:2011-01-19 07:33:32
【问题描述】:

我想知道是否可以在 applescript 中创建一个脚本,我们将应用程序名称和数字 N 作为输入作为输入,所以这个应用程序在 Space 的空间号 N 中打开。

我想用它来创建一个元苹果脚本,所以当计算机启动并登录后,在每个空间上我都会得到不同的应用程序,重要的是,我可以在脚本文件中更改它,而不是通过 mac os x空间偏好

谢谢

【问题讨论】:

  • 当前接受的答案似乎不适用于 10.8。有人知道怎么做吗?
  • 那么 OSX 10.9 Mavericks 呢? :)

标签: macos applescript


【解决方案1】:

在 OS X 10.5 或 10.6 中,Spaces 分配可以通过脚本接口访问和更改为System Events.app

tell application "System Events"
    set x to application bindings of spaces preferences of expose preferences
    set x to {|com.apple.textedit|:4} & x  -- Have TextEdit appear in space 4
    set application bindings of spaces preferences of expose preferences to x
end tell

如果您还不知道,可以从 Finder 中获取应用程序的 bundle id:

tell application "Finder"
    get id of application file "TextEdit" of folder "Applications" of startup disk
end tell

【讨论】:

  • 这太棒了!只是欲望问题,我怎样才能将 textedit 更改为 Thunderbird?
  • 请注意,在 OS X 10.7 中,“空间首选项”对象又消失了
  • 空间首选项在 10.10 和 10.11(测试版)中也不可用。 :-(
【解决方案2】:

这可以切换到空间 2,然后返回到空间 1:

tell application "System Events"
    key code 19 using {control down} -- control+2 is switch to Display Space 2
end tell
delay 1.0

tell application "System Events"
    key code 18 using {control down} -- control+1 is switch to Display Space 1
end tell
delay 1.0

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-08
    • 1970-01-01
    • 2017-12-26
    • 1970-01-01
    • 2011-08-07
    • 2014-03-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多