如何在 applescript 中将仪表板首选项更改为 "As Overlay"
How to change the Dashboard Preferences to "As Overlay" in 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"
谢谢
要将仪表板设置设置为“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
代码)
我正在制作一个 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"
谢谢
要将仪表板设置设置为“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
代码)