abdulrahmanok

Read Date From menu

18 posts in this topic

#1 ·  Posted (edited)

Hi Brothers Thank you all for your efforts I have this data :

 
<TR>
<TD CLASS="dddefault">
<SELECT NAME="selected_day">
<OPTION VALUE="14-OCT-16">14-OCT-16
<OPTION VALUE="13-OCT-16">13-OCT-16
<OPTION VALUE="12-OCT-16">12-OCT-16
<OPTION VALUE="11-OCT-16">11-OCT-16
<OPTION VALUE="10-OCT-16">10-OCT-16
</SELECT>
</TR>

I want to Get "Selected day " values into Variables and write it to msgbox or txt file

for example :

Value 1 = selected day,1

Because the date changes every day so i can't expect witch text written in 

Solved :

Ty All Brothers

Edited by abdulrahmanok

Share this post


Link to post
Share on other sites



try this one bro 

Local $selectedday = _IEGetObjByName($oIE, "selected_day")
MsgBox(0, "Value", $selectedday.value)

 

Share this post


Link to post
Share on other sites

Or this one:

Local $sFilePath = @ScriptDir & "\test.txt"


; Read the current script file into an array using the filepath.
Local $aArray = FileReadToArray($sFilePath)
If @error Then
    MsgBox(0, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
Else
    For $i = 0 To UBound($aArray) - 1 ; Loop through the array.
        $iString = StringInStr($aArray[$i], "OPTION VALUE")
        If $iString > 1 Then
            $sMyString = StringMid($aArray[$i], 16, 9)
            MsgBox(0, "My String", $sMyString)
        Else
            ContinueLoop
        EndIf
    Next
EndIf

 

Share this post


Link to post
Share on other sites
6 hours ago, Muhammad_Awais_Sharif said:

try this one bro 

Local $selectedday = _IEGetObjByName($oIE, "selected_day")
MsgBox(0, "Value", $selectedday.value)

 

(97) : ==> Variable must be of type "Object".:
MsgBox(0, "Value", $selectedday.value)
MsgBox(0, "Value", $selectedday^ ERROR

 

Share this post


Link to post
Share on other sites
5 hours ago, l3ill said:

Or this one:

Local $sFilePath = @ScriptDir & "\test.txt"


; Read the current script file into an array using the filepath.
Local $aArray = FileReadToArray($sFilePath)
If @error Then
    MsgBox(0, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
Else
    For $i = 0 To UBound($aArray) - 1 ; Loop through the array.
        $iString = StringInStr($aArray[$i], "OPTION VALUE")
        If $iString > 1 Then
            $sMyString = StringMid($aArray[$i], 16, 9)
            MsgBox(0, "My String", $sMyString)
        Else
            ContinueLoop
        EndIf
    Next
EndIf

 

didn't show error and also didn't show msgbox or edit text

Share this post


Link to post
Share on other sites
11 minutes ago, l3ill said:

did you save your example text as test.txt

works fine here...

Sure I did .. but   very strange  its like the program bypass this code and go to next code

Share this post


Link to post
Share on other sites
1 minute ago, l3ill said:

???

you should get 5 consecutive msgbox's with the 5 dates.

is that not happening?

Yes there is nothing , and i notice now where there is not something like this in your code:
 

$oLinks = _IETagNameGetCollection($oIE, "input")

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

You could also try this:

#Include <Array.au3>
#Include <String.au3>
$sText=FileRead('IE_Snipet.txt')    ;replace this with _IEBodyReadHTML
$aDate=_StringBetween($sText,'<SELECT NAME="selected_day">','</SELECT>')
If IsArray($aDate) Then $aDate=_StringBetween($aDate[0],'OPTION VALUE="','">')
If IsArray($aDate) Then
    _ArrayDisplay($aDate)
Else
    ConsoleWrite('Nothing found')
EndIf

Text is data from your opening post.

But it isn't realy needed to do it this way.

8 hours ago, abdulrahmanok said:

Because the date changes every day so i can't expect witch text written in 

If the first option is always today you can also calculate the other options with _DateAdd and some stringmanipulations.

 

Edited by AutoBert

Share this post


Link to post
Share on other sites

#11 ·  Posted

39 minutes ago, AutoBert said:

#Include <Array.au3> #Include <String.au3> $sText=FileRead('IE_Snipet.txt') ;replace this with _IEBodyReadHTML $aDate=_StringBetween($sText,'<SELECT NAME="selected_day">','</SELECT>') If IsArray($aDate) Then $aDate=_StringBetween($aDate[0],'OPTION VALUE="','">') If IsArray($aDate) Then _ArrayDisplay($aDate) Else ConsoleWrite('Nothing found') EndIf

;replace this with _IEBodyReadHTML  Sorry for noob question but how to do this ?

do you mean replace  $sText=FileRead by _IEBodyReadHTML?

Share this post


Link to post
Share on other sites

#12 ·  Posted

Just now, abdulrahmanok said:

do you mean replace  $sText=FileRead by _IEBodyReadHTML?

no i mean replace $sText=_IEBodyReadHTML($oIE). Like example in helpfile.

Share this post


Link to post
Share on other sites

#13 ·  Posted

Its stuck again in code and didn't show any result this is full code please check it 
 

Local $aArray = FileReadToArray($sFilePath)
If @error Then
    MsgBox(0, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
Else
    For $i = 0 To UBound($aArray) - 1 ; Loop through the array.
        $iString = StringInStr($aArray[$i], "OPTION VALUE")
        If $iString > 1 Then
            $sMyString = StringMid($aArray[$i], 16, 9)
            MsgBox(0, "My String", $sMyString)
        Else
            ContinueLoop
        EndIf
    Next
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Your Code :

$sText=_IEBodyReadHTML($oIE)    ;replace this with _IEBodyReadHTML
$aDate=_StringBetween($sText,'<SELECT NAME="selected_day">','</SELECT>')
If IsArray($aDate) Then $aDate=_StringBetween($aDate[0],'OPTION VALUE="','">')
If IsArray($aDate) Then
    _ArrayDisplay($aDate)
Else
    ConsoleWrite('Nothing found')
EndIf

MsgBox(0,"Passed","Continue")

I created msg box to check but i cant even see "Passed","Continue"

that's mean debug stuck in previous code

Share this post


Link to post
Share on other sites

#14 ·  Posted

You are mixing 2 difernetly ways to solve. If you would try my solution, than

  1. run script as i posted in https://www.autoitscript.com/forum/topic/185030-read-date-from-menu/?do=findComment&comment=1328997  using IE_Snipet.txt
  2. After change my script replacing line 3 with this 2 lines:
    $oIE=_IECreate('YourUrl')   ;change to your real URL
    $sText=_IEBodyReadHTML($oIE)

    and run again.  In both cases you get a array with the dates: 

  3. 107_ArrayDisplay.jpg

IE_Snipet.txt

1 person likes this

Share this post


Link to post
Share on other sites

#15 ·  Posted

5 hours ago, AutoBert said:

You are mixing 2 difernetly ways to solve. If you would try my solution, than

  1. run script as i posted in https://www.autoitscript.com/forum/topic/185030-read-date-from-menu/?do=findComment&comment=1328997  using IE_Snipet.txt
  2. After change my script replacing line 3 with this 2 lines:
    $oIE=_IECreate('YourUrl')   ;change to your real URL
    $sText=_IEBodyReadHTML($oIE)

    and run again.  In both cases you get a array with the dates: 

  3. 107_ArrayDisplay.jpg

IE_Snipet.txt

Tyyy Finally its worked i was need to Add (sleep) before your code to wait page until loading
I have final request if you can , I need to set this variables in text for example :

text lane 1 = [row0]

text lane2 = [row1]

Share this post


Link to post
Share on other sites

#16 ·  Posted

Thank You All Brothers little search and i found the code this is full code :
#Include <Array.au3>
#Include <String.au3>
#include <file.au3>
 

$sText=_IEBodyReadHTML($oIE)
$aDate=_StringBetween($sText,'<SELECT NAME="selected_day">','</SELECT>')
If IsArray($aDate) Then $aDate=_StringBetween($aDate[0],'OPTION VALUE="','">')
If IsArray($aDate) Then
    _ArrayDisplay($aDate)
    MsgBox(0,"",$aDate[0])
    MsgBox(0,"",$aDate[1])
        MsgBox(0,"",$aDate[2])
            MsgBox(0,"",$aDate[3])
MsgBox(0,"",$aDate[4])

Else
    ConsoleWrite('Nothing found')
EndIf

Special Thanks To @AutoBert

     

Share this post


Link to post
Share on other sites

#17 ·  Posted

extend script with

For $i=0 To UBound($aDate) -1 
    MsgBox(0,$i&':',$aDate[$i]
Next

and you will see how to output specific element of the array. I suggest also reading wiki about Arrays .

Share this post


Link to post
Share on other sites

#18 ·  Posted

32 minutes ago, AutoBert said:

extend script with

For $i=0 To UBound($aDate) -1 
    MsgBox(0,$i&':',$aDate[$i]
Next

and you will see how to output specific element of the array. I suggest also reading wiki about Arrays .

Ty Again I Appreciate to you , I'm started to understand Arrays now a bit and I'm trying to read about

it more .

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