AL3X Posted January 25, 2008 Share Posted January 25, 2008 (edited) -- Edited July 2, 2015 by AL3X Link to comment Share on other sites More sharing options...
GaryFrost Posted January 26, 2008 Share Posted January 26, 2008 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: expandcollapse popupWhile 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 More sharing options...
AL3X Posted January 26, 2008 Author Share Posted January 26, 2008 (edited) -- Edited July 2, 2015 by AL3X Link to comment Share on other sites More sharing options...
GaryFrost Posted January 26, 2008 Share Posted January 26, 2008 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 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 More sharing options...
AL3X Posted January 26, 2008 Author Share Posted January 26, 2008 (edited) -- Edited July 2, 2015 by AL3X Link to comment Share on other sites More sharing options...
AL3X Posted January 27, 2008 Author Share Posted January 27, 2008 (edited) -- Edited July 2, 2015 by AL3X Link to comment Share on other sites More sharing options...
AL3X Posted January 28, 2008 Author Share Posted January 28, 2008 (edited) -- Edited July 2, 2015 by AL3X Link to comment Share on other sites More sharing options...
erezlevi Posted January 28, 2008 Share Posted January 28, 2008 Juu, nobody knows how to make the script to read just once the text ? I really nead it 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 More sharing options...
AL3X Posted January 28, 2008 Author Share Posted January 28, 2008 (edited) -- Edited July 2, 2015 by AL3X Link to comment Share on other sites More sharing options...
AL3X Posted January 28, 2008 Author Share Posted January 28, 2008 (edited) -- Edited July 2, 2015 by AL3X Link to comment Share on other sites More sharing options...
erezlevi Posted January 29, 2008 Share Posted January 29, 2008 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: expandcollapse popup#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 More sharing options...
erezlevi Posted January 29, 2008 Share Posted January 29, 2008 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 More sharing options...
BrettF Posted January 29, 2008 Share Posted January 29, 2008 _TalkOBJ($texto = "") should fail shouldn't it? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
AL3X Posted January 29, 2008 Author Share Posted January 29, 2008 (edited) -- Edited July 2, 2015 by AL3X Link to comment Share on other sites More sharing options...
BrettF Posted January 29, 2008 Share Posted January 29, 2008 LOL !!! It works !!! :P:D:D:D:DThanks 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 MUHAHHAHAAThanks Read the func. If the text is blank, it doesn't talk. Why do I smell a prank... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
erezlevi Posted January 29, 2008 Share Posted January 29, 2008 Read the func. If the text is blank, it doesn't talk. Why do I smell a prank... 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 More sharing options...
BrettF Posted January 29, 2008 Share Posted January 29, 2008 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... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
erezlevi Posted January 29, 2008 Share Posted January 29, 2008 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 More sharing options...
AL3X Posted January 29, 2008 Author Share Posted January 29, 2008 (edited) -- Edited July 2, 2015 by AL3X Link to comment Share on other sites More sharing options...
erezlevi Posted January 29, 2008 Share Posted January 29, 2008 What is prank ? (I'm not english )Hey, there is another bug xD jajaThe script gets the text from the window, and speak's it. But if the window is closed beforethe script finish to speak the text, it will say all the time "pue pue pue pue pue" xDI'll try to fix it myself 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now