如何在AppleScript中将仪表板首选项更改为“As Overlay”

时间:2015-11-26 05:58:26

标签: applescript

我正在制作一个自动将仪表板小部件添加到桌面的AppleScript。为此,我需要将仪表板设置设置为“As Overlay”而不是“As Space”或“Off”。这是在系统偏好设置>任务控制。另外,如何在按下return / enter键之前停止脚本?这就是我所要做的(不改变设置或输入键):

set icon to (path to me as string) & "Contents:Resources:icon.icns" on delay duration set endTime to (current date) + duration repeat while (current date) is less than endTime tell AppleScript to delay duration end repeat end delay delay 2 do shell script "defaults write com.apple.dashboard devmode YES" delay 2 do shell script "killall Dock" delay 3 display dialog "Click and hold to select a widget" with title "DeskWidget" buttons {"Cancel", "Choose a Widget"} default button 2 with icon file icon delay 2 tell application "System Events" key code 111 end tell

return / enter键会在这里,但我只有delay 2

tell application "System Events" key code 111 end tell delay 3 do shell script "killall Dock"

由于

1 个答案:

答案 0 :(得分:0)

将信息中心设置设置为" As Overlay " (在 El Capitan 上测试),请使用:

do shell script "defaults write com.apple.dashboard 'dashboard-enabled-state' -int 3 && defaults write com.apple.dashboard 'enabled-state' -int 2 && sleep 2 && killall Dock"

要获得按下的键:AppleScript无法实现,这应该可以在Cocoa-Applet中使用(AppleScriptObjC代码)