爲您解答: 1:超時爲mcgrailm國家使用;但是儘量只寫
with timeout of 2 second --no plural
<your code here>
end timeout
2:在彈出的對話框取景器彈出,因此你的腳本不能看到的是,「嘗試錯誤」不會被調用的錯誤永遠不會返回到腳本,所以如果你想自動點擊確定,那麼這個代碼將起作用。此代碼將在超時秒後點擊該按鈕。
try
<your code here>
on error
tell application "System Events"
keystroke return
end tell
end try
我也包括我的版本,我在家裏使用這個腳本執行網絡的檢查同樣的想法的,然後嘗試安裝使用shell安裝卷。我最初使用了一個超時發現器「掛載音量」,並且這些代碼也作爲內嵌評論存在,但我不喜歡彈出錯誤對話框;即使只有一秒鐘,所以我轉向shell腳本。
--------------------------------------------------------------------------------------
--"Basic Drive Mounter.app"
try
set IP_address to "xxx.xxx.xxx.xxx"
set IP_Valid to true
try
do shell script ("ping -c 2 " & IP_address)
on error
set IP_Valid to false
end try
if IP_Valid then
tell application "Finder"
if disk "work" exists then
else
try
do shell script "mkdir /Volumes/work"
end try
do shell script "mount_afp afp://xxx.xxx.xxx.xxx/work /Volumes/work/"
-->>finder mount volume version
--with timeout of 2 second
-- mount volume "afp://xxx.xxx.xxx.xxx/work"
--end timeout
--<<finder mount volume version
end if
end tell
end if
on error
return 0
-->>finder mount volume version
--on error finder returns an error dialog which needs to be closed to go back and retry
--tell application "System Events"
-- keystroke return
--end tell
--<<finder mount volume version
end try
--------------------------------------------------------------------------------------
該腳本忽略超時並需要大約2分鐘發送警告。與之前相同的東西。 :( – reinaldoluckman 2010-03-06 03:07:10
你接受了我的回答,那麼你的工作對你來說還是需要修改我的代碼? – mcgrailm 2010-03-22 13:03:55