我是Applescript的新手。我做了一些搜索,閱讀和發現的東西,應該用於激活菜單項工作:在Applescript中,我試圖激活Seamonkey中的一個菜單項。
on do_menu(app_name, menu_name, menu_item)
try
-- bring the target application to the front
tell application app_name
activate
end tell
tell application "System Events"
tell process app_name
tell menu bar 1
tell menu bar item menu_name
tell menu menu_name
click menu item menu_item
end tell
end tell
end tell
end tell
end tell
return true
on error error_message
return false
end try
end do_menu
-- In my case I want to start Seamonkey and open the Composer window (and select it) so I
-- do:
do_menu("SeaMonkey", "Windows", "Composer")
當我運行該事件日誌窗口顯示:
tell application "SeaMonkey"
activate
end tell
tell application "System Events"
click menu item "Composer" of menu "Windows" of menu bar item "Windows" of menu bar 1 of process "SeaMonkey"
--> error number -1728 from «class mbri» "Windows" of «class mbar» 1 of «class prcs» "SeaMonkey"
end tell
結果: 假
我看不出我做錯了什麼。