Уважаемые форумчане! Есть скрипт с MsAgent в нем нужно добавить две опции - автоматическим чтением персонажем данных из буфера обмена и проговаривание даты время. Искал примеры в инете ,безрезультатно! Если кто то может направить ,помогите!!!
VB.NET / VBA:
Dim AgentControl
Dim Merlin
Dim UsedChars
Dim MerlinID
Dim MerlinACS
Dim MerlinLoaded
Dim HideReq
Dim Req
Dim ScriptComplete
UsedChars = "Merlin"
MerlinID = "Merlin"
MerlinACS = "merlin.acs"
MerlinLoaded = False
ScriptComplete = False
Call Main
Function IsAgentInstalled()
On Error Resume Next
If ScriptEngineMajorVersion < 2 Then
IsAgentInstalled = False
Else
Set AgentControl = WScript.CreateObject("Agent.Control.2", "AgentControl_")
IsAgentInstalled = (Not AgentControl Is Nothing)
End If
End Function
Sub Main()
On Error Resume Next
If Not IsAgentInstalled() Then
Exit Sub
End If
AgentControl.Connected = True
MerlinLoaded = LoadLocalChar(MerlinID, MerlinACS)
If Not MerlinLoaded Then
MerlinLoaded = LoadLocalChar(MerlinID, "")
End If
If MerlinLoaded Then
Call SetCharObj
Call AgentIntro
Else
Call LoadError
End If
End Sub
Function LoadLocalChar(ByVal CharID, ByVal CharACS)
On Error Resume Next
If CharACS = "" Then
AgentControl.Characters.Load CharID, CharACS
Else
AgentControl.Characters.Load CharID, CharACS
End If
If Err = 0 Then
LoadLocalChar = True
Exit Function
End If
LoadLocalChar = False
End Function
Sub SetCharObj()
On Error Resume Next
Set Merlin = AgentControl.Characters(MerlinID)
Merlin.LanguageID = &H409
End Sub
Sub AgentControl_RequestComplete(ByVal RequestObject)
On Error Resume Next
If RequestObject <> EndReq Then
Else
If Not Merlin.Visible Then
ScriptComplete = True
Else
End If
End If
If RequestObject <> HideReq Then
Else
AgentControl.Characters.Unload MerlinID
ScriptComplete = True
End If
End Sub
Sub LoadError()
Dim strMsg
strMsg = "Error Loading Character: " & MerlinID
strMsg = strMsg & Chr(13) & Chr(13) & "This Microsoft Agent Script requires the character(s):"
strMsg = strMsg & Chr(13) & UsedChars
MsgBox strMsg, 48
End Sub
Sub AgentControl_Click(ByVal CharacterID, ByVal Button, ByVal Shift, ByVal X, ByVal Y)
End Sub
Sub AgentControl_DblClick(ByVal CharacterID, ByVal Button, ByVal Shift, ByVal X, ByVal Y)
On Error Resume Next
Merlin.StopAll
If Not MerlinID.HasOtherClients Then
If Merlin.Visible Then
Set HideReq = Merlin.Hide()
Else
AgentControl.Characters.Unload MerlinID
ScriptComplete = True
End If
End If
End Sub
Sub InitAgentCommands()
Merlin.Commands.RemoveAll
Merlin.Commands.Caption = "MASH Menu"
Merlin.Commands.Add "ACO", "Advanced Character Options", "Advanced Character Options"
Merlin.Commands.Add "Exit", "Exit", "Exit"
End Sub
Sub AgentControl_Command(ByVal UserInput)
On Error Resume Next
Dim BadConfidence
BadConfidence = 10
If (UserInput.Confidence <= -40) Then
' Bad Recognition
Exit Sub
ElseIf (UserInput.Alt1Name <> "") And Abs(Abs(UserInput.Alt1Confidence) - Abs(UserInput.Confidence)) < BadConfidence Then
' Bad Confidence - too close to another command
Exit Sub
ElseIf (UserInput.Alt2Name <> "") And Abs(Abs(UserInput.Alt2Confidence) - Abs(UserInput.Confidence)) < BadConfidence Then
' Bad Confidence - too close to another command
Exit Sub
Else ' High Confidence
Select Case UserInput.Name
Case "ACO"
AgentControl.PropertySheet.Visible = True
End Select
If UserInput.Name = "Exit" Then
Set HideReq = Merlin.Hide()
End If
End If
End Sub
Sub AgentControl_Bookmark(ByVal BookmarkID)
On Error Resume Next
End Sub
Sub AgentIntro()
On Error Resume Next
Call InitAgentCommands
Merlin.Show
Merlin.Play "Acknowledge"
Merlin.Think "ПРЕВЕД, Чукча!!!!!!"
Set EndReq = Merlin.Speak("\mrk=999999999\")
Do
WScript.Sleep 1000
Loop Until ScriptComplete
End Sub
Последнее редактирование модератором: