0
我的腳本從AppA獲取一些文本並將其粘貼到AppB上的文本編輯中。當AppB啓動時(通過腳本),文本編輯被禁用,當用戶執行操作時變爲啓用狀態。該行動需要保持手動。AppleScript啓用編輯框
該腳本在用戶有時間處理任何事情之前執行錯誤。我的想法是檢查是否啓用了編輯,但是出現此錯誤。 「無法獲得應用程序」系統事件「的AppB的AppB窗口>」AppB「,它只會拋出一次錯誤。
如何避免錯誤?嘗試阻止只吃錯誤更好?
on idle
tell application "System Events" to set AppAIsOpen to (application process "AppA" exists)
if (AppAIsOpen) then
set AppAWasOpen to true
tell application "AppA"
set hdg to TxRprt
set beam to hdg as string
end tell
if ((count beam) < 3) then set beam to text -3 thru -1 of ("000" & beam)
if (beam is not previousText) then
tell application "AppB" to launch
tell application "System Events"
tell application process "AppB"
if text field 1 of window "AppB" is enabled then -- error here
set value of text field 1 of window "AppB" to beam --or here
end if
end tell
end tell
set previousText to beam
end if
return checkInterval
else if (AppAgWasOpen) then
quit
return 1
end if
結束閒置
這很好用。謝謝。 – Mike 2013-02-25 03:21:46