Jump to content

--


AL3X
 Share

Recommended Posts

Hi ! I want to make a script that waits until some window with information/error/cuestion from the sistem apear, and then "read" & "speak" the text from the windows.

Example: When you delete files, the sistem ask you "Are you sure ......?"

I want to make my script read this.

Here is what I have:

While 1
$ventana = WinWaitActive("[CLASS:#32770]", "")
$texto = WinGetText($ventana, "")

_TalkOBJ($texto)
WEnd
Func _TalkOBJ($s_text)
    Local $o_speech
    $o_speech = ObjCreate("SAPI.SpVoice")
    $o_speech.Speak ($s_text)
    $o_speech = ""
EndFunc ;==>_TalkOBJoÝ÷ Ø­Â+a¶¬¶¬r¸©¶·©y«l¶­{_®­ì"Ú0° Ý×hzÉí­ëk÷­ê®¢ÚÞjZ®¢Û^ÆØ­ë-ël²)Ý¡û-®)à³ú®¢×+¢é]v¸¯{*.ëliû^­©¢ë^¢»p¢Øb³¬ªè©Ýv*íÉ«­¢+Ù!½Ñ-åMÐ ÅÕ½ÐííM
ôÅÕ½Ðì°ÅÕ½Ðí}Qɵ¥¹ÑÅÕ½Ðì¤()±¥¹± ÅÕ½Ðí5å1¥Õ¹ÅÕ½Ðì¤()]¡¥±Ä(%M±À ÄÀ¤)]¹()Õ¹5å1¥Õ¹ ¤(%%]¥¹á¥ÍÑÌ ÅÕ½Ðí
½¹¥É´¥±±ÑÅÕ½Ðì¤Q¡¸($%]¥¹Ñ¥ÙÑ ÅÕ½Ðí
½¹¥É´¥±±ÑÅÕ½Ðì¤($%]¥¹]¥ÑÑ¥Ù ÅÕ½Ðí
½¹¥É´¥±±ÑÅÕ½Ðì¤($$ÀÌØíÑáѼô
½¹Ñɽ±ÑQáÐ ÅÕ½Ðí
½¹¥É´¥±±ÑÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíMÑÑ¥ÈÅÕ½Ðì¤($%}Q±­=   ( ÀÌØíÑáѼ¤(%¹%)¹Õ¹ìôôÐí5å1¥Õ¹()Õ¹}Qɵ¥¹Ñ ¤(%á¥Ð)¹Õ¹ìôôÐí}Qɵ¥¹Ñ()Õ¹}Q±­= ( ÀÌØíÍ}ÑáФ(%1½°ÀÌØí½}ÍÁ ($ÀÌØí½}ÍÁ ô=©
ÉÑ ÅÕ½ÐíMA$¹MÁY½¥ÅÕ½Ðì¤($ÀÌØí½}ÍÁ ¹MÁ¬ ÀÌØíÍ}ÑáФ($ÀÌØí½}ÍÁ ôÅÕ½ÐìÅÕ½Ðì)¹Õ¹ìôôÐí}Q±­=   oÝ÷ Ù*&¶§©hazX§zʵìm¶)yç!jëh×6#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiEdit.au3>

HotKeySet("{ESC}", "_Terminate")

Global $hEdit, $sText = ""

_Main()

Func _Main()

    ; Create GUI
    GUICreate("Edit Create", 400, 300)
    $hEdit = GUICtrlCreateEdit("Type something and press enter", 2, 2, 394, 268)
    GUISetState()

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

Func _Terminate()
    Exit
EndFunc   ;==>_Terminate

Func _TalkOBJ($s_text)
    Local $o_speech
    $o_speech = ObjCreate("SAPI.SpVoice")
    $o_speech.Speak($s_text)
    $o_speech = ""
EndFunc   ;==>_TalkOBJ

Func _Edit_Changed($hWnd)
    Local $sTempText = StringReplace(StringReplace(_GUICtrlEdit_GetText($hEdit), @CRLF, Chr(13)), @LF, Chr(13))
    If $sTempText <> $sText And StringInStr(StringMid($sTempText, StringLen($sText) + 1), Chr(13)) Then
        If StringLen($sText) Then $sTempText = StringReplace($sTempText, $sText, "")
        _TalkOBJ($sTempText)
        $sText = StringReplace(StringReplace(_GUICtrlEdit_GetText($hEdit), @CRLF, Chr(13)), @LF, Chr(13))
        $sTempText = ""
    EndIf
EndFunc   ;==>_Edit_Changed

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit
    If Not IsHWnd($hEdit) Then $hWndEdit = GUICtrlGetHandle($hEdit)
    $hWndFrom = $ilParam
    $iIDFrom = _WinAPI_LoWord($iwParam)
    $iCode = _WinAPI_HiWord($iwParam)
    Switch $hWndFrom
        Case $hEdit, $hWndEdit
            Switch $iCode
                Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control
                    _Edit_Changed($hWnd)
                    ; no return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

HotKeySet("{ESC}", "_Terminate")

AdlibEnable("MyAdLibFunc")

While 1
    Sleep(10)
WEnd

Func MyAdLibFunc()
    If WinExists("Confirm File Delete") Then
        WinActivate("Confirm File Delete")
        WinWaitActive("Confirm File Delete")
        $texto = ControlGetText("Confirm File Delete", "", "Static2")
        _TalkOBJ($texto)
    EndIf
EndFunc   ;==>MyAdLibFunc

Func _Terminate()
    Exit
EndFunc   ;==>_Terminate

Func _TalkOBJ($s_text)
    Local $o_speech
    $o_speech = ObjCreate("SAPI.SpVoice")
    $o_speech.Speak($s_text)
    $o_speech = ""
EndFunc   ;==>_TalkOBJ

But this way, the script will wait only for the "delete dialog". I want to make the script to "read" the text from all windows with class #32770 :D

How can I do this ?

I gave you what you need, just modify it to do what you want.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Juu, nobody knows how to make the script to read just once the text ?

I really nead it :D

Help me, please.

just use a var:

AdlibEnable("MyAdLibFunc")
$i = 0
While 1
    Sleep(10)
    
WEnd

Func MyAdLibFunc()
    If WinExists("Confirm File Delete") Then
        WinActivate("Confirm File Delete")
        WinWaitActive("Confirm File Delete")
        $texto = ControlGetText("Confirm File Delete", "", "Static2")
        If $i = 0 Then
            _TalkOBJ($texto)
        Else
            Exit
        EndIf
    EndIf
EndFunc  ;==>MyAdLibFunc

Func _Terminate()
    Exit
EndFunc  ;==>_Terminate

Func _TalkOBJ($s_text)
    Local $o_speech
    $o_speech = ObjCreate("SAPI.SpVoice")
    $o_speech.Speak($s_text)
    $o_speech = ""
    $i = 1
EndFunc  ;==>_TalkOBJ

look at $i

Link to comment
Share on other sites

If I could do something like this:

If $i = 0 Then
            _TalkOBJ($texto)
        Else
            MAGICAL FUNCTION TO START THE SCRIPT FROM THE BEGGINING
        EndIf

Its possible ?

solution:

#AutoIt3Wrapper_run_debug_mode=Y
HotKeySet("{ESC}", "_Terminate")

AdlibEnable("MyAdLibFunc")
$i = 0
Global $m1
While 1
    Sleep(10)
    
WEnd

Func MyAdLibFunc()
    If WinExists("Confirm File Delete") Then
        
        WinActivate("Confirm File Delete")
        WinWaitActive("Confirm File Delete")
        $texto = ControlGetText("Confirm File Delete", "", "Static2")
    ;MsgBox(0, "this is $m1:", $m1)
        If $m1 = $texto Then
            _TalkOBJ($texto = "")
        Else
            _TalkOBJ($texto)
            
        EndIf
        
        
    EndIf
EndFunc  ;==>MyAdLibFunc

Func _Terminate()
    Exit
EndFunc  ;==>_Terminate

Func _TalkOBJ($s_text)
    Local $o_speech
    If $s_text = "" Then Return
    
    $o_speech = ObjCreate("SAPI.SpVoice")
    $o_speech.Speak($s_text)
    $o_speech = ""
    $m1 = ControlGetText("Confirm File Delete", "", "Static2")
;MsgBox(0, "$m1:", $m1)
    Return $m1
EndFunc  ;==>_TalkOBJ

see $s_text and $m1, I would use select and switch here because with func you can't terminate wisely.... but if Gary wrote it.... then because he is GOD then I should shut up.

Link to comment
Share on other sites

Hi me again.

just wanted to tell you couple of things:

1) don't expect a Moderator (like Gary) to solve looping/Math problems for you, you should do it yourself.

2) Gary did gave you what you needed, the modification should become familier to you.

my advice:

1) use the help file, and FAQs.

2) allways login to this Forum (at least twice a week) and download some examples, and solution that moderators/developers/MVPs writes. this is how I am learning AutoIT. save those examples to your SciTe.

3) try to solve things by your own. this is why they will never give you the full solution because it is too easy, and you will never learn that way!

hope it will help you.

Link to comment
Share on other sites

LOL !!!

It works !!! :P :P:D:D:D:D

Thanks A LOT !!! (L)

But, only one thing ;)

With this : If $m1 = $texto Then

_TalkOBJ($texto = "")

you make the script the "speak" no text, right ?

I'll save this in somewhere safe :P MUHAHHAHAA

Thanks ;)

Read the func. If the text is blank, it doesn't talk. Why do I smell a prank... :D
Link to comment
Share on other sites

Read the func. If the text is blank, it doesn't talk. Why do I smell a prank... :D

bert, hi my friend.

I don't know how to exit a If statement that is why I used his current func. if he would use Select and cases it was much easier... do you know how to exit an IF ?

Link to comment
Share on other sites

bert, hi my friend.

I don't know how to exit a If statement that is why I used his current func. if he would use Select and cases it was much easier... do you know how to exit an IF ?

Confused...
Link to comment
Share on other sites

Confused...

here are the lines:

If $m1 = $texto Then
            _TalkOBJ($texto = "")
        Else
            _TalkOBJ($texto)
            
        EndIf

If the $m1=$texto I need to restart the Func MyAdLibFunc(). I don't know how to do it. this is why I send "" to _TalkOBJ because it is returning to the first function eventually.

Link to comment
Share on other sites

What is prank ? (I'm not english :P )

Hey, there is another bug xD jaja

The script gets the text from the window, and speak's it. But if the window is closed before

the script finish to speak the text, it will say all the time "pue pue pue pue pue" xD

I'll try to fix it myself :D

Thanks for the help !

Hi, again.

you can block the user from tuching the controls until it finishes. I will let you find out how... search in this forum...

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...