mendrofa Posted April 9, 2016 Posted April 9, 2016 why my string between is 0 expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> #include <String.au3> #include <Array.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 238, 66, 192, 124) $Group1 = GUICtrlCreateGroup("", 6, 0, 225, 57) $Input1 = GUICtrlCreateInput("", 14, 21, 121, 21) $Button1 = GUICtrlCreateButton("START", 150, 19, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Select Case $nmsg = $button1 cek() Case $nmsg = $GUI_EVENT_CLOSE Exit EndSelect WEnd func cek() Local $oie $url = "https://www.binary.com/trading?l=EN" If NOT WinExists("Binary.com") Then $oie = _IECreate($url, 2) Sleep(50) Else $oie = _IEAttach("Binary.com", "instance", 1) ;WinActivate("Binary.com") Sleep(50) EndIf Sleep(50) Do $o_akun = _iegetobjbyid($oie, "client_loginid") Until IsObj($o_akun) ConsoleWrite($o_akun.innerhtml & @CRLF) Sleep(50) $array = _StringBetween($o_akun.innerhtml, '"value="', '">"') guictrlsetdata($input1, $array) EndFunc
Developers Jos Posted April 9, 2016 Developers Posted April 9, 2016 On 4/9/2016 at 8:20 AM, mendrofa said: why my string between is 0 Expand Because an Array is returned when it finds the string, so you need to change that to $array[0] for the first found string. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
mendrofa Posted April 9, 2016 Author Posted April 9, 2016 like this ? expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> #include <String.au3> #include <Array.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 238, 66, 192, 124) $Group1 = GUICtrlCreateGroup("", 6, 0, 225, 57) $Input1 = GUICtrlCreateInput("", 14, 21, 121, 21) $Button1 = GUICtrlCreateButton("START", 150, 19, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Select Case $nmsg = $button1 cek() Case $nmsg = $GUI_EVENT_CLOSE Exit EndSelect WEnd func cek() Local $oie $url = "https://www.binary.com/trading?l=EN" If NOT WinExists("Binary.com") Then $oie = _IECreate($url, 2) Sleep(50) Else $oie = _IEAttach("Binary.com", "instance", 1) ;WinActivate("Binary.com") Sleep(50) EndIf Sleep(50) Do $o_akun = _iegetobjbyid($oie, "client_loginid") Until IsObj($o_akun) ConsoleWrite($o_akun.innerhtml & @CRLF) Sleep(50) $array = _StringBetween($o_akun.innerhtml, '"value="', '">"')[0] guictrlsetdata($input1, $array) EndFunc but error Func _StringBetween($sString, $sStart, $sEnd, $iMode = $STR_ENDISSTART, $bCase = False) Func _StringBetween($sString, $sStart, $sEnd, $iMode = $STR_E^ ERROR
Developers Jos Posted April 9, 2016 Developers Posted April 9, 2016 No did you check the helpfile? It is like this: $array = _StringBetween($o_akun.innerhtml, '"value="', '">"') guictrlsetdata($input1, $array[0]) Also ensure you do a test for @error to make sure the UDF found the string. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
mendrofa Posted April 9, 2016 Author Posted April 9, 2016 still error sir "F:\data2\cekprofit.au3" (46) : ==> Subscript used on non-accessible variable.: guictrlsetdata($input1, $array[0]) guictrlsetdata($input1, $array^ ERROR
Developers Jos Posted April 9, 2016 Developers Posted April 9, 2016 Please re-read my post and try to understand it first before posting that it doesn't work: On 4/9/2016 at 9:12 AM, Jos said: Also ensure you do a test for @error to make sure the UDF found the string. Expand SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
mendrofa Posted April 9, 2016 Author Posted April 9, 2016 sorry i newbie here sir how to test for @error
Developers Jos Posted April 9, 2016 Developers Posted April 9, 2016 (edited) I am sorry too but am not going to do all coding for you and you should be able to figure out how to do a if that will test the returned @error value. There is also a ConsoleWrite in your script that returns NOTHING, which I guess makes clear to you that you are doing something wrong with the text retrieval from the IE page. You wrote the script so what is it supposed to do? Jos Edited April 9, 2016 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Miloud Posted April 9, 2016 Posted April 9, 2016 try this: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> #include <String.au3> #include <Array.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 238, 66, 192, 124) $Group1 = GUICtrlCreateGroup("", 6, 0, 225, 57) $Input1 = GUICtrlCreateInput("", 14, 21, 121, 21) $Button1 = GUICtrlCreateButton("START", 150, 19, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Select Case $nmsg = $button1 cek() Case $nmsg = $GUI_EVENT_CLOSE Exit EndSelect WEnd func cek() Local $oie $url = "https://www.binary.com/trading?l=EN" If NOT WinExists("Binary.com") Then $oie = _IECreate($url, 2) Sleep(50) Else $oie = _IEAttach("Binary.com", "instance", 1) ;WinActivate("Binary.com") Sleep(50) EndIf Sleep(50) Do $o_akun = _iegetobjbyid($oie, "client_loginid") Until IsObj($o_akun) ConsoleWrite($o_akun.innerhtml & @CRLF) Sleep(50) $array = _StringBetween($o_akun.innerhtml, '"value="', '">"') $error= @error if VarGetType($array)='Array' Then $data=$array[0] Else $data=$error EndIf MsgBox(0,0,($data==1?'No strings found':$data )) ;guictrlsetdata($input1, $array) EndFunc Note that .... the innerHTML of the entry is null. <select id="client_loginid" name="client_loginid"> </select>
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