Command 物件

[Microsoft 代理程式在 Windows 7 中已被取代,且在後續版本的 Windows 中可能無法使用。]

Command 物件是Commands集合中的專案。 當您的用戶端應用程式變成輸入作用中時,伺服器會提供使用者對 Command 物件的存取權。

若要存取 Command 物件的 屬性,您可以使用其 Name 屬性在其集合中參考它。 在 VBScript 和 Visual Basic 中,您可以直接使用 Name 屬性:

   <i>agent</i>.Characters("<i>CharacterID</i>").Commands("<i>Name</i>").<i>property</i> [= <i>value</i>]

針對不支援集合的程式設計語言,請使用 Command 方法:

   <i>agent</i>.Characters("<i>CharacterID</i>").Commands.Command("<i>Name</i>").<i>property</i> [= <i>value</i>]

您也可以藉由建立 Command 物件的參考來參考命令物件。 在 Visual Basic 中,宣告物件變數,並使用 Set 語句來建立參考:

   Dim Cmd1 as Object
   ...
   Set Cmd1 = Agent.Characters("MyCharacterID").Commands("SampleCommand")
   ...
   Cmd1.Enabled = True

在 Visual Basic 5.0 中,您也可以將物件宣告為 IAgentCtlCommandEx 類型,並建立參考。 此慣例可啟用早期系結,這會導致效能更佳:

   Dim Cmd1 as IAgentCtlCommandEx
   ...
   Set Cmd1 = Agent.Characters("MyCharacterID").Commands("SampleCommand")
   ...
   Cmd1.Enabled = True

在 VBScript 中,您可以將參考宣告為特定類型,但您仍然可以宣告變數,並將它設定為集合中的 Command

   Dim Cmd1
   ...
   Set Cmd1 = Agent.Characters("MyCharacterID").Commands("SampleCommand")
   ...
   Cmd1.Enabled = True

命令可能會出現在字元的快顯視窗和命令視窗,或兩者中。 若要出現在快顯視窗中,它必須有標題,並將Visible屬性設定為True。 此外,其 Commands 集合物件 Visible 屬性也必須設定為 True。 若要出現在 [命令] 視窗中, 命令 必須設定其 CaptionVoice 屬性。 請注意,當功能表顯示時,字元的快顯功能表項不會變更。 如果您在顯示字元的快顯視窗時新增或移除命令或變更其屬性,則每當使用者下次顯示命令時,功能表就會顯示這些變更。 不過,命令視窗會動態反映您所做的任何變更。

下表摘要說明 Command 的屬性如何影響其呈現方式:

Caption 屬性

Voice-Caption屬性

Voice 屬性

Visible 屬性

Enabled 屬性

出現在字元的快顯視窗功能表中

出現在命令視窗中

Yes

Yes

Yes

True

True

一般,使用Caption

是,使用VoiceCaption

Yes

Yes

Yes

已停用,使用Caption

No

Yes

Yes

False

True

未顯示

是,使用VoiceCaption

Yes

Yes

False

未顯示

No

Yes

No

True

True

一般,使用Caption

No

Yes

No

已停用,使用Caption

No

Yes

No

False

True

未顯示

No

Yes

No

False

未顯示

No

No

Yes

Yes

True

True

未顯示

是,使用VoiceCaption

No

Yes

Yes

未顯示

No

No

Yes

False

True

未出現

是,使用VoiceCaption

No

Yes

False

未出現

No

No

No

True

True

未出現

No

No

No

未出現

No

No

No

False

True

未出現

No

No

No

False

未出現

No

No

Yes

True

True

一般,使用Caption

是,使用Caption

No

Yes

已停用,使用Caption

No

No

False

True

未出現

是,使用Caption

No

False

未出現

No

No

No

True

True

一般,使用Caption

No

No

No

已停用,使用Caption

No

No

No

False

True

未出現

No

No

No

False

未出現

No

No

No

Yes

True

True

未出現

No

No

No

Yes

未出現

No

No

No

False

True

未出現

No

No

No

False

未出現

No

No

No

No

True

True

未出現

No

No

No

No

未出現

No

No

No

No

False

True

未出現

No

No

No

No

False

未出現

No

如果屬性設定為 Null。 在某些程式設計語言中,空字串可能不會解譯為 Null 字串。 命令仍可透過語音存取。

當伺服器收到其中一個命令的輸入時,它會傳送 Command 事件,並將 Command 的名稱傳回為 UserInput 物件的屬性。 然後,您可以使用條件陳述式來比對和處理 Command