Hello,
First of all sry for the tittle but i couldn't find something better atm.
Ok so, i am trying to automate Chrome browser.
I got the FF.au3 UDF and tried to change it in Chrome so i could make use to it but i am getting problems...
I never used TCP before so im not sure im understanding the entire code.
This is what i made until now:
Consolewrite im getting is:
__GCSend ==> Socket Error
_GCComand ==> Error return value
I m four hours here making this thing to work but i cant get it fixed.
All ideas would be greatly appreciated
Edit: Reading the developer site of mozilla i think i got it a bit wrong...
First of all sry for the tittle but i couldn't find something better atm.
Ok so, i am trying to automate Chrome browser.
I got the FF.au3 UDF and tried to change it in Chrome so i could make use to it but i am getting problems...
I never used TCP before so im not sure im understanding the entire code.
This is what i made until now:
[ autoit ]
#Region Global Constants Global Const $_GC_PROC_NAME = "chrome.exe" Global Const $_GC_COM_DELAY_MAX = 200 Global Enum $_GC_ERROR_Success = 0, _ $_GC_ERROR_GeneralError, _ $_GC_ERROR_SocketError, _ $_GC_ERROR_InvalidDataType, _ $_GC_ERROR_InvalidValue, _ $_GC_ERROR_SendRecv, _ $_GC_ERROR_Timeout, _ $_GC_ERROR___UNUSED, _ $_GC_ERROR_NoMatch, _ $_GC_ERROR_RetValue, _ $_GC_ERROR_ReplException, _ $_GC_ERROR_InvalidExp<b></b>ression #EndRegion Global Constants #Region Global Variables Global $_GC_GLOBAL_SOCKET = -1 Global $_GC_CON_DELAY Global $_GC_LOADWAIT_TIMEOUT = 120000 Global $_GC_LOADWAIT_STOP = True Global $_GC_COM_TRACE = True Global $_GC_ERROR_MSGBOX = True Global $_GC_FRAME = 'top' Global $_GC_SEARCH_MODE = 0 #EndRegion Global Variables _GCAction("back") Func _GCAction($sAction, $vOption = "", $vOption2 = "", $bLoadWait = True) Local Const $sFuncName = "_GCAction" Local $sCommand Local $sActionL = StringLower($sAction) Select Case $sActionL = "back" $sCommand = "gBrowser.goBack()" Case $sActionL = "home" $sCommand = "gBrowser.goHome()" Case $sActionL = "forward" $sCommand = "gBrowser.goForward()" EndSelect Local $sRet = _GCComand($sCommand) If Not @error Then Return $sRet Else SetError(@error) Return "" EndIf EndFunc Func _GCComand($sArg, $iTimeOut = 30000) Local Const $sFuncName = "_GCComand" Local $sRet If StringLeft($sArg, 1) = "." Then $sArg = "window.content.document" & $sArg Local $sArgWrapped = StringReplace($sArg, "window.content.document", "window.content.wrappedJSObject.document") $sArg = StringReplace($sArg, "window.content.document", "window.content." & $_GC_FRAME & ".document") $sArgWrapped = StringReplace($sArgWrapped, "window.content.wrappedJSObject.document", "window.content.wrappedJSObject." & $_GC_FRAME & ".document") If (Not StringInStr($sArg, ".frames[")) Or StringInStr($sArg, "evaluate") Or (Not StringRegExp($sArg, "\.[a-zA-z]+\(.*?\)(\[.+\])?\.", 0)) Then If __GCSend($sArg) Then $sRet = __GCRecv($iTimeOut) If Not @error Or String($sRet) <> "_GCComand_Err" Then Return $sRet ElseIf StringInStr($sArgWrapped, "wrappedJSObject") Then __GCSend($sArgWrapped) $sRet = __GCRecv($iTimeOut) If Not @error And String($sRet) <> "_GCComand_Err" Then Return $sRet EndIf EndIf Else __GCSend($sArgWrapped) $sRet = __GCRecv($iTimeOut) If Not @error And String($sRet) <> "_GCComand_Err" Then Return $sRet EndIf SetError(__GCError($sFuncName, $_GC_ERROR_RetValue, $sRet)) Return "" EndFunc Func __GCError($sWhere, Const ByRef $i_FF_ERROR, $sMessage = "") Local $sOut, $sMsg Sleep(200) Switch $i_FF_ERROR Case $_GC_ERROR_Success Return $_GC_ERROR_Success Case $_GC_ERROR_GeneralError $sOut = "General Error" Case $_GC_ERROR_SocketError $sOut = "Socket Error" Case $_GC_ERROR_InvalidDataType $sOut = "Invalid data type" Case $_GC_ERROR_InvalidValue $sOut = "Invalid value" Case $_GC_ERROR_Timeout $sOut = "Timeout" Case $_GC_ERROR_NoMatch $sOut = "No match" Case $_GC_ERROR_RetValue $sOut = "Error return value" Case $_GC_ERROR_SendRecv $sOut = "Error TCPSend / TCPRecv" Case $_GC_ERROR_ReplException $sOut = "MozRepl Exception" Case $_GC_ERROR_InvalidExp<b></b>ression $sOut = "Invalid Exp<b></b>ression" EndSwitch If $sMessage = "" Then $sMsg = $sWhere & " ==> " & $sOut & @CRLF ConsoleWriteError($sMsg) Else $sMsg = $sWhere & " ==> " & $sOut & ": " & $sMessage & @CRLF ConsoleWriteError($sMsg) EndIf Return $i_FF_ERROR EndFunc ;==>__FFError Func __GCSend($sCommand) Local Const $sFuncName = "__GCSend" If Not __GCIsSocket($_GC_GLOBAL_SOCKET) Then SetError(__GCError($sFuncName, $_GC_ERROR_SocketError)) Return 0 EndIf TCPSend($_GC_GLOBAL_SOCKET, $sCommand & @CRLF) If Not @error Then If $_GC_COM_TRACE Then ConsoleWrite("__GCSend: " & $sCommand & @CRLF) Return 1 Else SetError(__GCError($sFuncName, $_GC_ERROR_SendRecv, "TCPSend: " & $sCommand)) Return 0 EndIf EndFunc Func __GCRecv($iTimeOut = 30000) Local $sRet = __GCWaitForRepl($iTimeOut) Local $iErr = @error $sRet = StringStripWS($sRet, 3) If StringLeft($sRet, 1) = '"' Then $sRet = StringTrimLeft($sRet, 1) If StringRight($sRet, 1) = '"' Then $sRet = StringTrimRight($sRet, 1) If $sRet = "true" Then $sRet = 1 ElseIf $sRet = "false" Then $sRet = 0 EndIf If $_GC_COM_TRACE Then ConsoleWrite("__FFRecv: " & $sRet & @CRLF) SetError($iErr) Return $sRet EndFunc Func __GCIsSocket(ByRef $Socket) Return ($Socket > 0 And IsInt($Socket)) EndFunc Func __GCWaitForRepl($iTimeOut) Local Const $sFuncName = @CRLF & "__GCWaitForRepl" Local $recv, $sRet = "", $TimeOutTimer = TimerInit() If $iTimeOut < 200 Then $iTimeOut = 200 While TimerDiff($TimeOutTimer) < $iTimeOut Sleep($_GC_CON_DELAY) $recv = TCPRecv($_GC_GLOBAL_SOCKET, 4096) If @error Then SetError(__GCError($sFuncName, $_GC_ERROR_SendRecv, "TCPRecv :" & @error)) Return "" EndIf $sRet &= $recv If StringRegExp($recv, "!!!(.*?)(TypeError|Exception|ReferenceError):?") Then $recv = StringLeft($recv, StringInStr($recv, "location") - 1) Sleep(200) SetError(__GCError($sFuncName, $_GC_ERROR_ReplException, StringStripWS($recv, 3))) __GCSend(";") Sleep(200) Return "" ElseIf StringInStr($recv, "....>") Then __GCSend(";") Sleep(200) SetError(__GCError($sFuncName, $_GC_ERROR_RetValue, "MozRepl ....>")) Return "" ElseIf StringInStr($recv, "beginning of the line to force evaluation") Then Sleep(500) EndIf If StringRegExp($recv, "repl[\d]?>") Then Return StringRegExpReplace($sRet, "repl[\d]?>", "") WEnd SetError(__GCError($sFuncName, $_GC_ERROR_Timeout, Round(TimerDiff($TimeOutTimer)) & "ms > " & $iTimeOut & "ms $iTimeOut")) Return "" EndFunc
Consolewrite im getting is:
__GCSend ==> Socket Error
_GCComand ==> Error return value
I m four hours here making this thing to work but i cant get it fixed.
All ideas would be greatly appreciated
Edit: Reading the developer site of mozilla i think i got it a bit wrong...