Jump to content
Sign in to follow this  
JScript

_MsAgent.au3 (Microsoft Agent)

Recommended Posts

JScript

Hello all,

This UDF is used for the Microsoft Agent Animations.

Current functions:

; ===============================================================================================================================
_MsAgent_Create( ["AgentName" [, Left [, Top]]] )
_MsAgent_SetState( [state] )
_MsAgent_GetState()
_MsAgent_Play( "Animation" )
_MsAgent_Stop()
_MsAgent_MoveTo( Left, Top )
_MsAgent_GetPos()
_MsAgent_SetPos( [Left [, Top]] )
_MsAgent_Speak( "Text" )
_MsAgent_Think( "Text" )
; ===============================================================================================================================

Any comments will be appreciated.

Download Link: _MSAgent.au3

Example:

1 - Run the script, $GUI_EVENT_SECONDARYUP show the merlin;

2 - Don't move the mouse or use the keyboard, see the effect!!!

3 - If you move the mouse or use keyboard, the Merlin will show other effects...

#include <GUIConstantsEx.au3>
#Include <Timers.au3>
#include <_MsAgent.au3>

$Form1 = GUICreate("_MsAgent.au3")
GUISetState(@SW_SHOW)


_MsAgent_Create()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            If BitAND(_MsAgent_GetState(), $GUI_SHOW) Then
                GUISetState(@SW_HIDE)
                _MsAgent_Stop()
                _MsAgent_Play('Wave')
                Sleep(2000)
                _MsAgent_SetState($GUI_HIDE)
                Sleep(2000)
            EndIf
            Exit
        Case $GUI_EVENT_MINIMIZE
            If BitAND(_MsAgent_GetState(), $GUI_SHOW) Then
                Local $aGetPos = _MsAgent_GetPos()
                _MsAgent_MoveTo($aGetPos[0], @DesktopHeight + 100)
            EndIf
        Case $GUI_EVENT_RESTORE
            If BitAND(_MsAgent_GetState(), $GUI_SHOW) Then
                Local $aGetPos = _MsAgent_GetPos()
                _MsAgent_MoveTo($aGetPos[0], $aGetPos[1])
            EndIf
        Case $GUI_EVENT_SECONDARYUP
            _MsAgent_SetState($GUI_SHOW)
            _GetAttention()
    EndSwitch
WEnd

Func _GetAttention()
    _MsAgent_Play('GetAttention')
    _MsAgent_Play('GetAttentionContinued')
    _MsAgent_Play('GetAttentionContinued')
    _MsAgent_Play('GetAttentionReturn')
    If _InKey(10) = 0 Then
        While _Timer_GetIdleTime() > 0
            _MsAgent_Play('Congratulate_2')
            If _InKey(10) = 0 Then
                Local $iRandom = Random(1, 35, 1)
                Switch $iRandom
                    Case 1 To 10
                        _MsAgent_Play('Decline')
                    Case 10 To 20
                        _MsAgent_Play('Announce')
                    Case 20 To 30
                        _MsAgent_Play('GetAttention')
                        _MsAgent_Play('GetAttentionContinued')
                        _MsAgent_Play('GetAttentionContinued')
                        _MsAgent_Play('GetAttentionReturn')
                    Case 30 To 35
                        _MsAgent_Play('Idle1_1')
                        _MsAgent_Play('Idle1_2')
                        _MsAgent_Play('Idle3_1')
                        _MsAgent_Play('Idle1_3')
                        _MsAgent_Play('Idle1_4')
                        _MsAgent_Play('Idle3_1')
                        _MsAgent_Play('Idle2_1')
                        _MsAgent_Play('Idle2_2')
                        _MsAgent_Play('Idle3_1')
                        _MsAgent_Play('Idle3_2')
                EndSwitch
                ContinueLoop
            EndIf
        WEnd
    EndIf
    _MsAgent_Stop()
    _MsAgent_Play('Read')
    _MsAgent_Speak('Olá ' & @ComputerName & ', chegou mensagem para você!')
    _MsAgent_Play('ReadContinued')
    _MsAgent_Play('ReadReturn')
EndFunc   ;==>_GetAttention

; #FUNCTION#=======================================================================================================================================
; Name...........: _InKey
; Description ...: Pauses the script until any key has been pressed or mouse activity.
; Syntax.........: InKey( TimeOut )
; Parameters ....: TimeOut  - Timeout in seconds. After the timeout has elapsed the script will be continue.
; Requirement(s).: #Include <Timers.au3>
; Return values .: Success - 1
;                  Failure - 0 If TimeOut
; Author ........: jscript
; Modified.......:
; Remarks .......:
; Related .......: Sleep and _IsPressed
; Link ..........:
; Example .......: _Inkey(5); Pauses script five seconds if no mouse activity or any key pressed...
;==================================================================================================================================================
Func _InKey($nTimeOut)
    Local $nTimer
    
    $nTimeOut = $nTimeOut & "000"
    
    $nTimer = TimerInit()
    While _Timer_GetIdleTime() > 0
        If TimerDiff($nTimer) > $nTimeOut Then Return 0 ; Timed out
        Sleep(10)
    WEnd
    Return 1
EndFunc   ;==>_InKey
Edited by jscript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites
Piyush

Hello all,

This UDF is used for the Microsoft Agent Animations.

Current functions:

; ===============================================================================================================================
_MsAgent_Create( ["AgentName" [, Left [, Top]]] )
_MsAgent_SetState( [state] )
_MsAgent_GetState()
_MsAgent_Play( "Animation" )
_MsAgent_Stop()
_MsAgent_MoveTo( Left, Top )
_MsAgent_GetPos()
_MsAgent_SetPos( [Left [, Top]] )
_MsAgent_Speak( "Text" )
_MsAgent_Think( "Text" )
; ===============================================================================================================================

Any comments will be appreciated.

#include-once
; #INDEX# =======================================================================================================================
; Title .........: _MsAgent (Microsoft Agent)
; AutoIt Version.: 3.2.12++
; Language.......: English
; Description ...: Microsoft Agent Animations.
; Remarks .......: The Microsoft Agent Merlin Character is a copyrighted work of Microsoft Corporation.
;                  Deprecated in Windows 7. This technology might not be available in later versions of Windows.
;                  Refer to Programming the Microsoft Agent Server Interface and Programming the Microsoft Agent Control for
;                  information on how to call the character's animations.
;                  Only the Merlin is supported.
; Author ........: João Carlos (jscript)
; ===============================================================================================================================

; #CURRENT# =====================================================================================================================
;_MsAgent_Create
;_MsAgent_SetState
;_MsAgent_GetState
;_MsAgent_Play
;_MsAgent_Stop
;_MsAgent_MoveTo
;_MsAgent_GetPos
;_MsAgent_SetPos
;_MsAgent_Speak
;_MsAgent_Think
; ===============================================================================================================================

; #INTERNAL_USE_ONLY#============================================================================================================
;==============================================================================================================================

; #VARIABLES# ===================================================================================================================
Global $oMsAgent_Object = 0
Global $sMsAgent_Obj_Default = "Merlin.acs"
Global $lMsAgent_Obj_State = 64
Global $aMsAgent_Obj_Pos[2] = [0, 0]
;==============================================================================================================================

; #FUNCTION# ====================================================================================================================
; Name...........: _MsAgent_Create
; Description ...: Load an Microsoft Agent Animation (load Search Assistant also).
; Syntax.........: _MsAgent_Create( ["AgentName" [, Left [, Top]]] )
; Parameters ....: AgentName - [optional] The name of msagent char. Default is "Merlin.acs". You can define the full path of MsAgent.
;                  Left      - [optional] The left position to show agent (right). Default is -1 (same position of last active window).
;                  Top       - [optional] The top position to show agent. Default is -1 (same position of last active window).
; Return values .: Success   - Returns 1.
;                  Failure   - Returns 0 and sets @error to:
;                                   1 - The only one agent is load at time.
;                                   2 - The agente file doesn't exist.
;                                   3 - Can't creates a reference to a COM object from the given classname.
;                                   4 - Can't creates the ActiveX control.
; Author ........: João Carlos (jscript)
; Modified.......:
; Remarks .......: This function attempts to embed an 'ActiveX Control' or a 'Document Object' inside the GUI.
;                  'Document Objects' will only be visible if the Windows style $WS_CLIPCHILDREN has been used in GUICreate().
;                  The GUI functions GUICtrlRead and GUICtrlSet have no effect on this control. The object can only be
;                  controlled using 'methods' or 'properties' on the $ObjectVar, see related.
; Related .......: _MsAgent_Show, _MsAgent_Hide, _MsAgent_Play, _MsAgent_Stop, _MsAgent_MoveTo and _MsAgent_Speak.
; Link ..........;
; Example .......; _MsAgent_Create()
; ===============================================================================================================================
Func _MsAgent_Create($sAgentName = "", $iLeft = -1, $iTop = -1)
    If IsObj($oMsAgent_Object) Then SetError(1, 0, 0)
    Local $iCtrlID, $sWinSrchAsst = @WindowsDir & "\srchasst\chars\"
    
    If $sAgentName = "" Then $sAgentName = "Merlin.acs"
    If Not StringInStr($sAgentName, ".acs", 0, -1) Then $sAgentName &= ".acs"
    
    If Not StringInStr($sAgentName, "\", 0, -1) Then
        If FileExists($sWinSrchAsst & $sAgentName) Then
            $sAgentName = $sWinSrchAsst & $sAgentName
        ElseIf FileExists(@ScriptDir & "\" & $sAgentName) Then
            $sAgentName = @ScriptDir & "\" & $sAgentName
        Else
            If Not FileExists(@WindowsDir & "\msagent\chars\" & $sAgentName) Then Return SetError(2, 0, 0)
        EndIf
    Else
        If Not FileExists($sAgentName) Then Return SetError(2, 0, 0)
    EndIf
    
    $oMsAgent_Object = ObjCreate("Agent.Control.2")
    If @error Then Return SetError(3, 0, 0)
    $iCtrlID = GUICtrlCreateObj($oMsAgent_Object, 0, 0, 32, 32)
    If $iCtrlID = 0 Then Return SetError(4, 0, 0)
    $oMsAgent_Object.Connected = 1
    $oMsAgent_Object.Characters.Load("MsAgent", $sAgentName)
    
    If $iLeft = -1 Or $iTop = -1 Then
        Local $aWinPos = WinGetPos("")
        If $iLeft = -1 Then $iLeft = ($aWinPos[0] + $aWinPos[2]) - 110
        If $iLeft > @DesktopWidth Then $iLeft = @DesktopWidth - 110
        If $iTop = -1 Then $iTop = $aWinPos[1] + 30
    EndIf
    $oMsAgent_Object.Characters.Character("MsAgent" ).MoveTo($iLeft, $iTop)
    $aMsAgent_Obj_Pos[0] = $iLeft
    $aMsAgent_Obj_Pos[1] = $iTop
    $lMsAgent_Obj_State = 64
    $sMsAgent_Obj_Default = $sAgentName
    Return 1
EndFunc   ;==>_MsAgent_Create

; #FUNCTION# ====================================================================================================================
; Name...........: _MsAgent_SetState
; Description ...: Set the state of Microsoft Agent.
; Syntax.........: _MsAgent_SetState( [state] )
; Parameters ....: state    - [optional] Set the state of the Microsoft Agent. Default is $GUI_SHOW, see remarks.
; Return values .: Success  - Returns 1.
;                  Failure  - Returns 0.
; Author ........: João Carlos (jscript)
; Modified.......:
; Remarks .......: Suported state values:
;                  _________________________________________________________________________
;                  $GUI_SHOW    -> MsAgent will be visible.
;                  $GUI_HIDE    -> MsAgent will not be visible.
;                  $GUI_ENABLE  -> MsAgent will be enabled.
;                  $GUI_DISABLE -> MsAgent will be disable.
;                  ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
;                  State values can be summed up as: $GUI_DISABLE + $GUI_HIDE.
; Related .......: _MsAgent_Create
; Link ..........;
; Example .......; _MsAgent_SetState()
; ===============================================================================================================================
Func _MsAgent_SetState($iState = 16)
    If Not IsObj($oMsAgent_Object) Then Return 0
    If (BitAND($iState, 64) And BitAND($iState, 128)) Or (BitAND($iState, 16) And BitAND($iState, 32)) Then Return 0
    
    If (BitAND($lMsAgent_Obj_State, 16) And BitAND($iState, 64)) Or _
            (BitAND($lMsAgent_Obj_State, 32) And BitAND($iState, 128)) Then $iState = BitOR($iState, $lMsAgent_Obj_State)
    If BitAND($iState, 16) Then $oMsAgent_Object.Characters.Character("MsAgent" ).Show
    If BitAND($iState, 32) Then $oMsAgent_Object.Characters.Character("MsAgent" ).Hide
    
    $lMsAgent_Obj_State = $iState
    Return 1
EndFunc   ;==>_MsAgent_SetState

; #FUNCTION# ====================================================================================================================
; Name...........: _MsAgent_GetState
; Description ...: Get the state of Microsoft Agent.
; Syntax.........: _MsAgent_GetState()
; Parameters ....:
; Return values .: Success  - Returns a value indicating the state of the Microsoft Agent. See remarks.
;                  Failure  - Returns 0.
; Author ........: João Carlos (jscript)
; Modified.......:
; Remarks .......: Multiple values are added together so use BitAND() to examine the part you are interested.
;                  _________________________________________________________________________
;                  $GUI_SHOW    -> MsAgent will be visible.
;                  $GUI_HIDE    -> MsAgent will not be visible.
;                  $GUI_ENABLE  -> MsAgent will be enabled.
;                  $GUI_DISABLE -> MsAgent will be disable.
;                  ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
; Related .......: _MsAgent_Create
; Link ..........;
; Example .......; _MsAgent_GetState()
; ===============================================================================================================================
Func _MsAgent_GetState()
    If Not IsObj($oMsAgent_Object) Then Return 0
    
    Return $lMsAgent_Obj_State
EndFunc   ;==>_MsAgent_GetState

; #FUNCTION# ====================================================================================================================
; Name...........: _MsAgent_Play
; Description ...: Animate Microsoft Agent.
; Syntax.........: _MsAgent_Play( "Animation" )
; Parameters ....: Animation - The object control identifier (controlID) as returned by a _MsAgent_Create function.
; Return values .: Success  - Returns 1.
;                  Failure  - Returns 0.
; Author ........: João Carlos (jscript)
; Modified.......:
; Remarks .......: If you play a looping animation, you must use _MsAgent_Stop to clear it before other animations in the
;                  character's queue will play.
; Related .......: _MsAgent_Show, _MsAgent_Stop, _MsAgent_Create
; Link ..........;
; Example .......; _MsAgent_Play( "Announce" )
; ===============================================================================================================================
Func _MsAgent_Play($sAnimation)
    If Not IsObj($oMsAgent_Object) Or BitAND($lMsAgent_Obj_State, 128) Then Return 0
    
    If $sMsAgent_Obj_Default = "Merlin.acs" Then
        Local $aTypes[75] = [74, "Acknowledge", "Alert", "Announce", "Blink", "Confused", "Congratulate", "Congratulate_2", "Decline", _
                "DoMagic1", "DoMagic2", "DontRecognize", "Explain", "GestureDown", "GestureLeft", "GestureRight", "GestureUp", _
                "GetAttention", "GetAttentionContinued", "GetAttentionReturn", "Greet", "Hearing_1", "Hearing_2", "Hearing_3", _
                "Hearing_3", "Hearing_4", "Hide", "Idle1_1", "Idle1_2", "Idle1_3", "Idle1_4", "Idle2_1", "Idle2_2", "Idle3_1", _
                "Idle3_2", "LookDown", "LookDownBlink", "LookDownReturn", "LookLeft", "LookLeftBlink", "LookLeftReturn", "LookRight", _
                "LookRightBlink", "LookRightReturn", "LookUp", "LookUpBlink", "LookUpReturn", "MoveDown", "MoveLeft", "MoveRight", _
                "MoveUp", "Pleased", "Process", "Processing", "Read", "ReadContinued", "ReadReturn", "Reading", "RestPose", "Sad", _
                "Search", "Searching", "Show", "StartListening", "StopListening", "Suggest", "Surprised", "Think", "Thinking", _
                "Uncertain", "Wave", "Write", "WriteContinued", "WriteReturn", "Writing"]
        Local $lFound = False
        
        For $i = 1 To $aTypes[0]
            If $sAnimation = $aTypes[$i] Then
                $lFound = True
                ExitLoop
            EndIf
        Next
        If Not $lFound Then Return 0
    EndIf
    
    $oMsAgent_Object.Characters.Character("MsAgent" ).Play($sAnimation)
    Return 1
EndFunc   ;==>_MsAgent_Play

; #FUNCTION# ====================================================================================================================
; Name...........: _MsAgent_Stop
; Description ...: Stop animation of Microsoft Agent.
; Syntax.........: _MsAgent_Stop()
; Parameters ....:
; Return values .: Success  - Returns 1.
;                  Failure  - Returns 0.
; Author ........: João Carlos (jscript)
; Modified.......:
; Remarks .......:
; Related .......: _MsAgent_Show, _MsAgent_Play, _MsAgent_Create
; Link ..........;
; Example .......; _MsAgent_Stop()
; ===============================================================================================================================
Func _MsAgent_Stop()
    If Not IsObj($oMsAgent_Object) Or BitAND($lMsAgent_Obj_State, 128) Then Return 0
    
    $oMsAgent_Object.Characters.Character("MsAgent" ).Stop()
    Return 1
EndFunc   ;==>_MsAgent_Stop

; #FUNCTION# ====================================================================================================================
; Name...........: _MsAgent_MoveTo
; Description ...: Move the Microsoft Agent.
; Syntax.........: _MsAgent_MoveTo( Left, Top )
; Parameters ....: Left      - The left position to move agent.
;                  Top       - The top position to move agent.
; Return values .: Success   - Returns 1.
;                  Failure   - Returns 0.
; Author ........: João Carlos (jscript)
; Modified.......:
; Remarks .......:
; Related .......: _MsAgent_Show, _MsAgent_Play, _MsAgent_Create
; Link ..........;
; Example .......; _MsAgent_MoveTo( 100, 100 )
; ===============================================================================================================================
Func _MsAgent_MoveTo($iLeft = -1, $iTop = -1)
    If Not IsObj($oMsAgent_Object) Or BitAND($lMsAgent_Obj_State, 128) Then Return 0
    
    $oMsAgent_Object.Characters.Character("MsAgent" ).MoveTo($iLeft, $iTop)
    Return 1
EndFunc   ;==>_MsAgent_MoveTo

; #FUNCTION# ====================================================================================================================
; Name...........: _MsAgent_GetPos
; Description ...: Get the position (left and top) of Microsoft Agent.
; Syntax.........: _MsAgent_GetPos()
; Parameters ....:
; Return values .: Success   - Returns a two-element array that containing the MsAgent coordinates:
;                              $array[0] = X coord (horizontal).
;                              $array[1] = Y coord (vertical).
;                  Failure   - Returns 0.
; Author ........: João Carlos (jscript)
; Modified.......:
; Remarks .......:
; Related .......: _MsAgent_SetPos, _MsAgent_MoveTo, _MsAgent_Show, _MsAgent_Play, _MsAgent_Create
; Link ..........;
; Example .......; _MsAgent_GetPos()
; ===============================================================================================================================
Func _MsAgent_GetPos()
    If Not IsObj($oMsAgent_Object) Or BitAND($lMsAgent_Obj_State, 128) Then Return 0
    
    Return $aMsAgent_Obj_Pos
EndFunc   ;==>_MsAgent_GetPos

; #FUNCTION# ====================================================================================================================
; Name...........: _MsAgent_SetPos
; Description ...: Set the new position for the Microsoft Agent.
; Syntax.........: _MsAgent_SetPos( [Left [, Top]] )
; Parameters ....: Left      - [optional] The left position to set agent. Deault is -1, no change left position.
;                  Top       - [optional] The top position to set agent. Deault is -1, no change top position.
; Return values .: Success   - Returns 1.
;                  Failure   - Returns 0.
; Author ........: João Carlos (jscript)
; Modified.......:
; Remarks .......:
; Related .......: _MsAgent_GetPos, _MsAgent_Show, _MsAgent_Play, _MsAgent_Create
; Link ..........;
; Example .......; _MsAgent_SetPos( 100, 100 )
; ===============================================================================================================================
Func _MsAgent_SetPos($iLeft = -1, $iTop = -1)
    If Not IsObj($oMsAgent_Object) Or BitAND($lMsAgent_Obj_State, 128) Then Return 0
    
    ;$oMsAgent_Object.Characters.Character("MsAgent").MoveTo($iLeft, $iTop)

    If $iLeft <> -1 Then $aMsAgent_Obj_Pos[0] = $iLeft
    If $iTop <> -1 Then $aMsAgent_Obj_Pos[1] = $iTop
    Return 1
EndFunc   ;==>_MsAgent_SetPos

; #FUNCTION# ====================================================================================================================
; Name...........: _MsAgent_Speak
; Description ...: Show the ToolTip whit an text for Microsoft Agent.
; Syntax.........: _MsAgent_Speak( "Text" )
; Parameters ....: Text     - The text to show in the ToolTip.
; Return values .: Success  - Returns 1.
;                  Failure  - Returns 0.
; Author ........: João Carlos (jscript)
; Modified.......:
; Remarks .......:
; Related .......: _MsAgent_Show, _MsAgent_Stop, _MsAgent_Create
; Link ..........;
; Example .......; _MsAgent_Speak( "Hello world!" )
; ===============================================================================================================================
Func _MsAgent_Speak($sText)
    If Not IsObj($oMsAgent_Object) Or BitAND($lMsAgent_Obj_State, 128) Then Return 0
    
    $oMsAgent_Object.Characters.Character("MsAgent" ).Speak($sText)
    Return 1
EndFunc   ;==>_MsAgent_Speak

; #FUNCTION# ====================================================================================================================
; Name...........: _MsAgent_Think
; Description ...: Show the ToolTip whit an text for Microsoft Agent.
; Syntax.........: _MsAgent_Think( "Text" )
; Parameters ....: Text     - The text to show in the ToolTip.
; Return values .: Success  - Returns 1.
;                  Failure  - Returns 0.
; Author ........: João Carlos (jscript)
; Modified.......:
; Remarks .......:
; Related .......: _MsAgent_Show, _MsAgent_Stop, _MsAgent_Speak, _MsAgent_Create
; Link ..........;
; Example .......; _MsAgent_Think( "Who orders in the world?" )
; ===============================================================================================================================
Func _MsAgent_Think($sText)
    If Not IsObj($oMsAgent_Object) Or BitAND($lMsAgent_Obj_State, 128) Then Return 0
    
    $oMsAgent_Object.Characters.Character("MsAgent" ).Speak($sText)
    Return 1
EndFunc   ;==>_MsAgent_Think

Example:

1 - Run the script, $GUI_EVENT_SECONDARYUP show the merlin;

2 - Don't move the mouse or use the keyboard, see the effect!!!

3 - If you move the mouse or use keyboard, the Merlin will show other effects...

#include <GUIConstantsEx.au3>
#Include <Timers.au3>
#include <_MsAgent.au3>

$Form1 = GUICreate("_MsAgent.au3")
GUISetState(@SW_SHOW)


_MsAgent_Create()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            If BitAND(_MsAgent_GetState(), $GUI_SHOW) Then
                GUISetState(@SW_HIDE)
                _MsAgent_Stop()
                _MsAgent_Play('Wave')
                Sleep(2000)
                _MsAgent_SetState($GUI_HIDE)
                Sleep(2000)
            EndIf
            Exit
        Case $GUI_EVENT_MINIMIZE
            If BitAND(_MsAgent_GetState(), $GUI_SHOW) Then
                Local $aGetPos = _MsAgent_GetPos()
                _MsAgent_MoveTo($aGetPos[0], @DesktopHeight + 100)
            EndIf
        Case $GUI_EVENT_RESTORE
            If BitAND(_MsAgent_GetState(), $GUI_SHOW) Then
                Local $aGetPos = _MsAgent_GetPos()
                _MsAgent_MoveTo($aGetPos[0], $aGetPos[1])
            EndIf
        Case $GUI_EVENT_SECONDARYUP
            _MsAgent_SetState($GUI_SHOW)
            _GetAttention()
    EndSwitch
WEnd

Func _GetAttention()
    _MsAgent_Play('GetAttention')
    _MsAgent_Play('GetAttentionContinued')
    _MsAgent_Play('GetAttentionContinued')
    _MsAgent_Play('GetAttentionReturn')
    If _InKey(10) = 0 Then
        While _Timer_GetIdleTime() > 0
            _MsAgent_Play('Congratulate_2')
            If _InKey(10) = 0 Then
                Local $iRandom = Random(1, 35, 1)
                Switch $iRandom
                    Case 1 To 10
                        _MsAgent_Play('Decline')
                    Case 10 To 20
                        _MsAgent_Play('Announce')
                    Case 20 To 30
                        _MsAgent_Play('GetAttention')
                        _MsAgent_Play('GetAttentionContinued')
                        _MsAgent_Play('GetAttentionContinued')
                        _MsAgent_Play('GetAttentionReturn')
                    Case 30 To 35
                        _MsAgent_Play('Idle1_1')
                        _MsAgent_Play('Idle1_2')
                        _MsAgent_Play('Idle3_1')
                        _MsAgent_Play('Idle1_3')
                        _MsAgent_Play('Idle1_4')
                        _MsAgent_Play('Idle3_1')
                        _MsAgent_Play('Idle2_1')
                        _MsAgent_Play('Idle2_2')
                        _MsAgent_Play('Idle3_1')
                        _MsAgent_Play('Idle3_2')
                EndSwitch
                ContinueLoop
            EndIf
        WEnd
    EndIf
    _MsAgent_Stop()
    _MsAgent_Play('Read')
    _MsAgent_Speak('Olá ' & @ComputerName & ', chegou mensagem para você!')
    _MsAgent_Play('ReadContinued')
    _MsAgent_Play('ReadReturn')
EndFunc   ;==>_GetAttention

; #FUNCTION#=======================================================================================================================================
; Name...........: _InKey
; Description ...: Pauses the script until any key has been pressed or mouse activity.
; Syntax.........: InKey( TimeOut )
; Parameters ....: TimeOut  - Timeout in seconds. After the timeout has elapsed the script will be continue.
; Requirement(s).: #Include <Timers.au3>
; Return values .: Success - 1
;                  Failure - 0 If TimeOut
; Author ........: jscript
; Modified.......:
; Remarks .......:
; Related .......: Sleep and _IsPressed
; Link ..........:
; Example .......: _Inkey(5); Pauses script five seconds if no mouse activity or any key pressed...
;==================================================================================================================================================
Func _InKey($nTimeOut)
    Local $nTimer
    
    $nTimeOut = $nTimeOut & "000"
    
    $nTimer = TimerInit()
    While _Timer_GetIdleTime() > 0
        If TimerDiff($nTimer) > $nTimeOut Then Return 0 ; Timed out
        Sleep(10)
    WEnd
    Return 1
EndFunc   ;==>_InKey

NICELY MADE....

[font="Comic Sans MS"][size="7"]Piyush.....[/size][/font][font="Palatino Linotype"][size="2"]Some Of My Scripts...Cool Font Generator Train Searcher and Tracer[/size][/font]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.