以下のスクリプトは、エラー処理を含むスクリプトを作成する方法を示しています。
Public Module Main Dim _desktop As Desktop = Agent.Desktop Public Sub Main() With _desktop.Window("@caption='Untitled - Notepad'") .TextField().TypeKeys("test", 0, False) .MenuItem("@caption='Font'").Select() Try With .Dialog("@caption='Font1'") ' throws an exception because such a dialog does not exist .ComboBox("@caption='Font style:'").Select("Regular") .ComboBox("@caption='Size:'").Select("14") .PushButton("@caption='Cancel'").Select() End With Catch ex As Exception With .Dialog("@caption='Font'") .ComboBox("@caption='Font style:'").Select("Regular") .ComboBox("@caption='Size:'").Select("14") .PushButton("@caption='Cancel'").Select() End With End Try End With End Sub End Module