Jump to content
Sign in to follow this  
Celtic88

help ! Error: The requested action with this object has failed.

Recommended Posts

Celtic88

ERROR ;'(

---------------------------

AutoIt Error

---------------------------

Line 104 (File "C:\Users\DOC\Desktop\GOOGLeE.au3"):

$oHTTP.Close

$oHTTP.Close^ ERROR

Error: The requested action with this object has failed.

---------------------------

OK

---------------------------

script :

; coded by Mrbenkali
Opt("GUIONEVENTMODE", 1)
Global $TITEL = "AUTOIT IS SIMPL ! "
Global $SCRIPTGUI = GUICreate($TITEL, 846, 550, -1, -1, 0X00040000)
GUISetOnEvent(-3, "__EXIT")
Global $EDIT1 = GUICtrlCreateEdit("", 0, 0, 844, 212)
GUICtrlSetFont($EDIT1, 24, 400, 0, "Arial")
Global $Edit2 = GUICtrlCreateEdit("", 0, 216, 844, 212, 3152064)
GUICtrlSetFont($Edit2, 24, 400, 0, "Arial")
GUICtrlSetBkColor($Edit2, 0XFFFFFF)
GUICtrlCreateGroup("TRANSLATE TO ", 8, 432, 830, 89)
Global $COMBO1 = GUICtrlCreateCombo("", 36, 471, 127, 25, 2097155)
GUICtrlSetOnEvent($COMBO1, "GOTRAN")
GUICtrlSetResizing($COMBO1, 65)
GUICtrlSetData($COMBO1, lGUI())
Global $Group1 = GUICtrlCreateGroup("SPEAK ", 364, 448, 437, 65)
Global $Label1 = GUICtrlCreateLabel("", 380, 476, 100, 17)
Global $BUTTON1 = GUICtrlCreateButton("SPEAK", 499, 468, 99, 33)
GUICtrlSetOnEvent($BUTTON1, "GOSPEAK")
GUICtrlSetResizing($BUTTON1, 65)
Global $Checkbox1 = GUICtrlCreateCheckbox("TRANSLATE TEXT", 647, 475, 121, 17)
GUISetState()
While True
Sleep(1000)
WEnd
Func GOSPEAK()
Local $readtxt
If GUICtrlRead($Checkbox1) = 1 Then
$readtxt = GUICtrlRead($Edit2)
Else
$readtxt = GUICtrlRead($EDIT1)
EndIf
If $readtxt = "" Then Return
WinSetTitle($SCRIPTGUI, "", "WAIT DOWNLOAD DATA...")
GOOGLESPEEK($readtxt)
WinSetTitle($SCRIPTGUI, "", $TITEL)
EndFunc ;==>GOSPEAK
Func GOTRAN()
Local $readtxt = GUICtrlRead($EDIT1)
If $readtxt = "" Then Return
WinSetTitle($SCRIPTGUI, "", "WAIT DOWNLOAD DATA...")
GOOGLETRANS($readtxt)
WinSetTitle($SCRIPTGUI, "", $TITEL)
EndFunc ;==>GOTRAN
Func LANGOG()
Return SLANG(GUICtrlRead($COMBO1), 2, 1)
EndFunc ;==>LANGOG
Func GOOGLETRANS($TEXTTOTRANS)
Local $TXT, $STEXT1, $STEXT, $STEXT2, $STEXT3, $READ, $ENCODESSTRING, $LANG
$LANG = DETLANG(StringLeft(StringRegExpReplace($TEXTTOTRANS, "\r\n|\r|\n", " "), 90), 1)
GUICtrlSetData($Label1, SLANG($LANG, 1))
GUICtrlSetData($Edit2, "")
$STEXT = StringSplit($TEXTTOTRANS, @CRLF, 1)
For $i = 1 To $STEXT[0]
$STEXT1 = StringSplit($STEXT[$i], " ")
For $O = 1 To $STEXT1[0]
$TXT &= $STEXT1[$O] & " "
If StringLen($TXT) > 90 Or $O = $STEXT1[0] Then
$STEXT2 = StringSplit($TXT, ".")
For $z = 1 To $STEXT2[0]
     $STEXT3 = StringSplit($STEXT2[$z], '"')
     For $L = 1 To $STEXT3[0]
     If StringIsSpace($STEXT3[$L]) Then ContinueLoop
     $ENCODESSTRING = URIENCODE($STEXT3[$L])
     $READ = DOWN("http://translate.google.com/translate_a/t?client=t&sl=auto&text=" & $ENCODESSTRING & "&tl=" & LANGOG())
     $DATA = StringSplit($READ, '"')
     GUICtrlSetData($Edit2, GUICtrlRead($Edit2) & $DATA[2])
     If $L <> $STEXT3[0] Then GUICtrlSetData($Edit2, GUICtrlRead($Edit2) & '"')
     $TXT = ""
     Next
     If $z <> $STEXT2[0] Then GUICtrlSetData($Edit2, GUICtrlRead($Edit2) & ".")
Next
EndIf
Next
If $i <> $STEXT[0] Then GUICtrlSetData($Edit2, GUICtrlRead($Edit2) & @CRLF)
Next
EndFunc ;==>GOOGLETRANS
Func GOOGLESPEEK($TEXTTOSPEEK)
Local $TXT, $OPEN, $STEXT1, $READ = "", $ENCODESSTRING, $RESTRING, $LANG, $MPFIL = FileGetShortName(@ScriptDir & "\" & Random(1, 99, 1) & ".MP3")
$RESTRING = StringRegExpReplace($TEXTTOSPEEK, "\r\n|\r|\n", " ")
$LANG = DETLANG(StringLeft($RESTRING, 90), 1)
GUICtrlSetData($Label1, SLANG($LANG, 1))
$STEXT1 = StringSplit($RESTRING, " ")
For $O = 1 To $STEXT1[0]
$TXT &= $STEXT1[$O] & " "
If StringLen($TXT) > 90 Or $O = $STEXT1[0] Then
$ENCODESSTRING = URIENCODE($TXT)
$READ &= StringTrimLeft(InetRead("http://translate.google.com/translate_tts?ie=UTF-8&tl=" & $LANG & "&q=" & $ENCODESSTRING, 1), 2)
$TXT = ""
EndIf
Next
$OPEN = FileOpen($MPFIL, 18)
FileWrite($OPEN, "0X" & $READ)
FileClose($OPEN)
ShellExecute(@AutoItExe, '/AUTOIT3EXECUTELINE "IF SOUNDPLAY(''' & $MPFIL & ''' ,1) THEN FILEDELETE(''' & $MPFIL & ''')"')
EndFunc ;==>GOOGLESPEEK
Func DOWN($URL)
Local $oHTTP
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET", $URL, False)
$oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1")
$oHTTP.Send("")
$oReceived = $oHTTP.ResponseText
$oHTTP.Close
Return $oReceived
EndFunc ;==>DOWN
Func URIENCODE($SDATA)
Local $ADATA = StringSplit(BinaryToString(StringToBinary($SDATA, 4), 1), "")
Local $NCHAR
$SDATA = ""
For $i = 1 To $ADATA[0]
ConsoleWrite($ADATA[$i] & @CRLF)
$NCHAR = Asc($ADATA[$i])
Switch $NCHAR
Case 45, 46, 48 To 57, 65 To 90, 95, 97 To 122, 126
$SDATA &= $ADATA[$i]
Case 32
$SDATA &= "+"
Case Else
$SDATA &= "%" & Hex($NCHAR, 2)
EndSwitch
Next
Return $SDATA
EndFunc ;==>URIENCODE
Func DETLANG($STRI, $OPTT)
Local $TST, $LANGGG
$TST = DOWN("http://translate.google.com/translate_a/t?client=t&sl=auto&text=" & URIENCODE(StringLeft($STRI, 33)))
$LANGGG = StringLeft(StringTrimLeft($TST, StringInStr($TST, '[["', 0, -1) + 2), 2)
Return $LANGGG
EndFunc ;==>DETLANG
Func SLANG($LANGG, $OPT, $OOPT = 2)
$SLIS = StringSplit(LISL(), ";")
For $i = 1 To $SLIS[0]
Local $GETl = StringSplit($SLIS[$i], "|")
If StringInStr($GETl[$OOPT], $LANGG, 2) Then
Return $GETl[$OPT]
EndIf
Next
EndFunc ;==>SLANG
Func lGUI()
Local $llol, $SLIS
$SLIS = StringSplit(LISL(), ";")
For $i = 1 To $SLIS[0]
$llol &= StringLeft($SLIS[$i], StringInStr($SLIS[$i], "|"))
Next
Return $llol
EndFunc ;==>lGUI
Func LISL()
Local $langlis = "Afrikaans|af;Albanian|sq;Arabic|ar;Armenian|hy;Azerbaijani|az;Basque|eu;Belarusian|be;Bengali|bn;Bulgarian|bg;Catalan|ca;Chinese|zh-CN;Croatian|hr;Czech|cs;Danish|da;Dutch|nl;English|en;Esperanto|eo;" & _
"Estonian|et;Filipino|tl;Finnish|fi;French|fr;Galician|gl;Georgian|ka;German|de;Greek|el;Gujarati|gu;Haitian Creole|ht;Hebrew|iw;Hindi|hi;Hungarian|hu;Icelandic|is;Indonesian|id;Irish|ga;Italian|it;" & _
"Japanese|ja;Kannada|kn;Khmer|km;Korean|ko;Lao|lo;Latin|la;Latvian|lv;Lithuanian|lt;Macedonian|mk;Malay|ms;Maltese|mt;Norwegian|no;Persian|fa;Polish|pl;Portuguese|pt;Romanian|ro;Russian|ru;" & _
"Serbian|sr;Slovak|sk;Slovenian|sl;Spanish|es;Swahili|sw;Swedish|sv;Tamil|ta;Telugu|te;Thai|th;Turkish|tr;Ukrainian|uk;Urdu|ur;Vietnamese|vi;Welsh|cy;Yiddish|yi"
Return $langlis
EndFunc ;==>LISL
Func __EXIT()
Exit
EndFunc ;==>__EXIT

Share this post


Link to post
Share on other sites
water

You have abolutely no error checking in your script.

Check @error after each function or add a COM error handler. Details can be found in the help file for ObjEvent.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
MouseSpotter

Answer: the method does not exist

Check you documentation for "winhttp.winhttprequest.5.1

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  

×