AppleScript在10810打开时失败;系统事件“;在第一次执行时。第二次执行效果很好
AppleScript在第一次执行时在“系统事件”上出现-10810时失败。如果立即再次执行,则第二次执行工作正常 代码:AppleScript在10810打开时失败;系统事件“;在第一次执行时。第二次执行效果很好,applescript,chef-infra,Applescript,Chef Infra,AppleScript在第一次执行时在“系统事件”上出现-10810时失败。如果立即再次执行,则第二次执行工作正常 代码: 行为: STDOUT: STDERR: 40:59: execution error: An error of type -10810 has occurred. (-10810) ---- End output of osascript -e ' tell application "System Events" keystroke "va
STDOUT:
STDERR: 40:59: execution error: An error of type -10810 has occurred. (-10810)
---- End output of osascript -e '
tell application "System Events"
keystroke "vagrant"
keystroke return
delay 3.0
keystroke "vagrant"
delay 3.0
keystroke tab
keystroke return
keystroke return
end tell
'
----
STDOUT:
STDERR: 66:75: execution error: An error of type -10810 has occurred. (-10810)
---- End output of osascript -e '
tell application "System Events"
tell process "Safari"
set frontmost to true
repeat until (exists window 1) and subrole of window 1 is "AXDialog" -- wait until the dialog is displayed.
delay 1
end repeat
click button 1 of front window -- install
end tell
'
----
因此,它在setup.rb中的告诉应用程序“系统事件”
时第一次失败
execute 'login to gui' do
command <<EOF
osascript -e '
tell application "System Events"
keystroke "vagrant"
keystroke return
delay 3.0
keystroke "vagrant"
delay 3.0
keystroke tab
keystroke return
keystroke return
end tell
'
EOF
end
第三次立即运行它,它就解决了第二个问题并成功地完成了
如果在再次运行之前等待几分钟,该行为会再次重复
以下是错误示例:
STDOUT:
STDERR: 40:59: execution error: An error of type -10810 has occurred. (-10810)
---- End output of osascript -e '
tell application "System Events"
keystroke "vagrant"
keystroke return
delay 3.0
keystroke "vagrant"
delay 3.0
keystroke tab
keystroke return
keystroke return
end tell
'
----
STDOUT:
STDERR: 66:75: execution error: An error of type -10810 has occurred. (-10810)
---- End output of osascript -e '
tell application "System Events"
tell process "Safari"
set frontmost to true
repeat until (exists window 1) and subrole of window 1 is "AXDialog" -- wait until the dialog is displayed.
delay 1
end repeat
click button 1 of front window -- install
end tell
'
----
尝试在第一行告诉应用程序“系统事件”之后插入
launch
命令。
系统事件在不活动5分钟后自动退出,这解释了“等待几分钟”行为
最后一个系统事件告诉块可以替换为
if application "Safari" is running then quit application "Safari"
尝试在第一行告诉应用程序“系统事件”之后插入
launch
命令。
系统事件在不活动5分钟后自动退出,这解释了“等待几分钟”行为
最后一个系统事件告诉块可以替换为
if application "Safari" is running then quit application "Safari"
谢谢你的退出应用提示。我尝试了启动,它导致了一个“应用程序未运行-600”错误。请参阅。问题是系统事件应用程序似乎要在chef运行之后才能运行。添加延迟似乎也无济于事。感谢您提供的退出应用程序提示。我尝试了启动,它导致了一个“应用程序未运行-600”错误。请参阅。问题是系统事件应用程序似乎要在chef运行之后才能运行。添加延迟似乎也没有帮助。我无法解决此问题。一个解决方法是在Chef中的执行资源中使用重试。我无法解决此问题。解决方法是在Chef中的execute资源中使用重试。