Jump to content

string between


Recommended Posts

why my string between is 0

#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

 

Link to comment
Share on other sites

  • Developers
30 minutes ago, mendrofa said:

why my string between is 0

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.
  :)

Link to comment
Share on other sites

like this ?

#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

Link to comment
Share on other sites

  • Developers

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.
  :)

Link to comment
Share on other sites

  • Developers

Please re-read my post and try to understand it first before posting that it doesn't work:

5 minutes ago, Jos said:

Also ensure you do a test for @error to make sure the UDF found the string.

 

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.
  :)

Link to comment
Share on other sites

  • Developers

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 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.
  :)

Link to comment
Share on other sites

try this:

#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>
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...