我最近使用Wine在我的Mac上安装了Warcraft3:TFT,因为Mac版本不支持 Lion。我使用Applescript编写了一个脚本来运行Wine的终端命令,然后禁用我的热点,这样我就不会有任何导航屏幕的问题。
我编写了脚本,它通过Applescript运行(Compile> Run)。当尝试将脚本保存为应用程序时,会出现真正的问题。我将其保存为应用程序然后尝试运行该应用程序(名为“魔兽争霸III - 冰封王座”)并得到此错误:
这是脚本本身:
set settings1 to {"-", "Desktop", "Start Screen Saver", "Mission Control"}
set settings2 to {"-", "-", "-", "-"}
tell application "Terminal"
do script "/opt/local/bin/wine ~/.wine/drive_c/Program\\ Files/Warcraft\\ III/war3.exe"
end tell
tell application "System Preferences"
reveal pane id "com.apple.preference.expose"
activate
tell application "System Events"
tell window "Mission Control" of process "System Preferences"
click button "Hot Corners…"
tell sheet 1
tell group 1
set theSettings to settings2
set functionKeys to false
repeat with k from 1 to 4
set theValue to item k of theSettings
tell pop up button k
if value is not theValue then
click
click menu item theValue of menu 1
end if
end tell
end repeat
end tell
click button "OK"
end tell
end tell
end tell
quit
end tell
display alert "Done playing?" buttons {"Yes"}
set response to button returned of the result
if response is "Yes" then
--Start return to normal settings
tell application "System Preferences"
reveal pane id "com.apple.preference.expose"
activate
tell application "System Events"
tell window "Mission Control" of process "System Preferences"
click button "Hot Corners…"
tell sheet 1
tell group 1
set theSettings to settings1
set functionKeys to true
repeat with k from 1 to 4
set theValue to item k of theSettings
tell pop up button k
if value is not theValue then
click
click menu item theValue of menu 1
end if
end tell
end repeat
end tell
click button "OK"
end tell
end tell
end tell
quit
end tell
--End return to normal settings
--quit X11 and terminal
tell application "X11"
quit
end tell
tell application "Terminal"
quit
end tell
end if
这是我第一次真正用Applescript写的,所以可能会出现一些我没有看到的错误。提前感谢任何建议或意见!
答案 0 :(得分:1)
您的错误代码与AppleScript无直接关系。错误-10810是发射服务错误代码,表示一般的,即未知错误。当OS X的进程表运行时,它似乎经常被抛出。有一个非常彻底的background post on the issue at the X Labs,有完整的分步说明来诊断(并可能补救)这个问题。
在OT备注中,我注意到您使用GUI脚本来打开或关闭Hot Corners。这是不必要的:Lion的系统事件可以通过其 Expose Preferences Suite 编写这些设置的脚本,即
property hotCornerSettings : {}
to disableHotCorners()
set hotCorners to {}
tell application "System Events"
tell expose preferences
set end of hotCorners to a reference to bottom left screen corner
set end of hotCorners to a reference to top left screen corner
set end of hotCorners to a reference to top right screen corner
set end of hotCorners to a reference to bottom right screen corner
repeat with hotCorner in hotCorners
set hotCornerProps to properties of hotCorner
set end of hotCornerSettings to {hotCorner, {activity:activity of hotCornerProps, modifiers:modifiers of hotCornerProps}}
set properties of hotCorner to {activity:none, modifiers:{}}
end repeat
end tell
end tell
end disableHotCorners
to restoreHotCorners()
tell application "System Events"
tell expose preferences
repeat with settings in hotCornerSettings
set properties of item 1 of settings to item 2 of settings
end repeat
end tell
end tell
end restoreHotCorners
...它可以让您免受GUI脚本的蠕虫攻击。