如何将此AppleScript转换为osascript?
我已经编写了一个AppleScript,希望将其转换为osascript,以便在启动时使用launchd运行它。有什么方法可以将其转换为osascript,还是必须将整个脚本重写为osascript?如果无法完成,是否至少有一种方法可以在终端中作为osascript运行它?谢谢大家!如何将此AppleScript转换为osascript?,applescript,launchd,login-script,osascript,Applescript,Launchd,Login Script,Osascript,我已经编写了一个AppleScript,希望将其转换为osascript,以便在启动时使用launchd运行它。有什么方法可以将其转换为osascript,还是必须将整个脚本重写为osascript?如果无法完成,是否至少有一种方法可以在终端中作为osascript运行它?谢谢大家! on idle tell application "System Events" to ¬ if exists process "Launchpad" then run script
on idle
tell application "System Events" to ¬
if exists process "Launchpad" then run script
tell application "Launchpad"
delay 0
tell application "System Events" to keystroke "b" using {control down, option down, command down}
delay 0
tell application "System Events" to keystroke "b" using {control down, option down, command down}
delay 0
tell application "System Events" to keystroke "b" using {control down, option down, command down}
delay 0
end tell
end idle
如果只需要每秒运行一次或更少的频率,可以将其另存为普通脚本:
tell application "System Events"
if not (exists process "Launchpad") then return
repeat 3 times
keystroke "b" using {control down, option down, command down}
end repeat
end tell
并使用launchd重复运行脚本:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN
http://www.apple.com/DTDs/PropertyList-1.0.dtd>
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.stackoverflow.11945633</string>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>/Users/username/Library/Scripts/script.scpt</string>
</array>
<key>StartInterval</key>
<integer>1</integer>
</dict>
</plist>
标签
com.stackoverflow.11945633
程序参数
奥萨Script
/Users/username/Library/Scripts/script.scpt
星际旅行社
1.
必须使用launchctl load~/Library/LaunchAgents/com.stackoverflow.11945633.plist
手动加载属性列表。应用更改需要卸载和加载它
默认情况下,程序在20秒后发送SIGKILL信号。您可以通过添加ExitTimeOut
键来覆盖超时。请参见人工发射.plist
该脚本实际上不适用于更改启动板背景。Launchpad.app只是一个虚拟应用程序,打开后会立即退出
如果您只想更改背景样式,可以使用
defaults write com.apple.dock springboard background filter-int 2;killall Dock
如果您只需要每秒运行一次或更少的频率,可以将其保存为普通脚本:
tell application "System Events"
if not (exists process "Launchpad") then return
repeat 3 times
keystroke "b" using {control down, option down, command down}
end repeat
end tell
并使用launchd重复运行脚本:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN
http://www.apple.com/DTDs/PropertyList-1.0.dtd>
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.stackoverflow.11945633</string>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>/Users/username/Library/Scripts/script.scpt</string>
</array>
<key>StartInterval</key>
<integer>1</integer>
</dict>
</plist>
标签
com.stackoverflow.11945633
程序参数
奥萨Script
/Users/username/Library/Scripts/script.scpt
星际旅行社
1.
必须使用launchctl load~/Library/LaunchAgents/com.stackoverflow.11945633.plist
手动加载属性列表。应用更改需要卸载和加载它
默认情况下,程序在20秒后发送SIGKILL信号。您可以通过添加ExitTimeOut
键来覆盖超时。请参见人工发射.plist
该脚本实际上不适用于更改启动板背景。Launchpad.app只是一个虚拟应用程序,打开后会立即退出
如果您只想更改背景样式,可以使用defaults write com.apple.dock springboard background filter-int 2;killall船坞