gpt4 book ai didi

applescript - 预期行尾等,但发现 “"”

转载 作者:行者123 更新时间:2023-12-01 12:47:34 24 4
gpt4 key购买 nike

我正在尝试制作一个可以切换蓝牙的 AppleScript,但我似乎无法克服以下错误:

Expected end of line, etc. but found “"”.

这是我的代码:
tell application "System Preferences"
reveal pane id "com.apple.preferences.Bluetooth"
tell application "System Events" to tell process "System Preferences"
set bluetooth to checkbox "On" of window 1
set bluetoothBool to value of checkbox "On" of window 1 as boolean
tell bluetooth
if bluetoothBool = false then
click bluetooth
display dialog "Bluetooth on" with title "Bluetooth"
buttons "OK" "Turn Bluetooth off"
default button "OK"
else if bluetoothBool = true then
click bluetooth
display dialog "Bluetooth off" with title "Bluetooth"
buttons "OK" "Turn Bluetooth on"
default button "OK"
end if
end tell
end tell
quit

结束告诉

最佳答案

"OK" "Turn Bluetooth off"需要{"OK", "Turn Bluetooth off"} .

另外,display dialog语句需要在一行中全部显示,除非您“继续”包含 ¬ 的一行,通过键入 Option-l(小写 L)输入。

tell application "System Preferences"
reveal pane id "com.apple.preferences.Bluetooth"
tell application "System Events" to tell process "System Preferences"
set bluetooth to checkbox "On" of window 1
set bluetoothBool to value of checkbox "On" of window 1 as boolean
tell bluetooth
if bluetoothBool = false then
click bluetooth
display dialog "Bluetooth on" with title ¬
"Bluetooth" buttons {"OK", "Turn Bluetooth off"} ¬
default button "OK"
else if bluetoothBool = true then
click bluetooth
display dialog "Bluetooth off" with title ¬
"Bluetooth" buttons {"OK", "Turn Bluetooth on"} ¬
default button "OK"
end if
end tell
end tell
quit
end tell

来源: AppleScript Language Guide

关于applescript - 预期行尾等,但发现 “"”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14465559/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com