abdulrahmanok Posted October 14, 2016 Posted October 14, 2016 (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 October 14, 2016 by abdulrahmanok
Muhammad_Awais_Sharif Posted October 14, 2016 Posted October 14, 2016 try this one bro Local $selectedday = _IEGetObjByName($oIE, "selected_day") MsgBox(0, "Value", $selectedday.value)
l3ill Posted October 14, 2016 Posted October 14, 2016 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 My Contributions... Reveal hidden contents SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
abdulrahmanok Posted October 14, 2016 Author Posted October 14, 2016 On 10/14/2016 at 5:10 AM, Muhammad_Awais_Sharif said: try this one bro Local $selectedday = _IEGetObjByName($oIE, "selected_day") MsgBox(0, "Value", $selectedday.value) Expand (97) : ==> Variable must be of type "Object".: MsgBox(0, "Value", $selectedday.value) MsgBox(0, "Value", $selectedday^ ERROR
abdulrahmanok Posted October 14, 2016 Author Posted October 14, 2016 On 10/14/2016 at 6:18 AM, 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 Expand didn't show error and also didn't show msgbox or edit text
l3ill Posted October 14, 2016 Posted October 14, 2016 did you save your example text as test.txt works fine here... My Contributions... Reveal hidden contents SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
abdulrahmanok Posted October 14, 2016 Author Posted October 14, 2016 On 10/14/2016 at 12:16 PM, l3ill said: did you save your example text as test.txt works fine here... Expand Sure I did .. but very strange its like the program bypass this code and go to next code
l3ill Posted October 14, 2016 Posted October 14, 2016 ??? you should get 5 consecutive msgbox's with the 5 dates. is that not happening? My Contributions... Reveal hidden contents SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
abdulrahmanok Posted October 14, 2016 Author Posted October 14, 2016 On 10/14/2016 at 12:34 PM, l3ill said: ??? you should get 5 consecutive msgbox's with the 5 dates. is that not happening? Expand Yes there is nothing , and i notice now where there is not something like this in your code: $oLinks = _IETagNameGetCollection($oIE, "input")
AutoBert Posted October 14, 2016 Posted October 14, 2016 (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. On 10/14/2016 at 4:43 AM, abdulrahmanok said: Because the date changes every day so i can't expect witch text written in Expand If the first option is always today you can also calculate the other options with _DateAdd and some stringmanipulations. Edited October 14, 2016 by AutoBert
abdulrahmanok Posted October 14, 2016 Author Posted October 14, 2016 On 10/14/2016 at 12:40 PM, 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 Expand ;replace this with _IEBodyReadHTML Sorry for noob question but how to do this ? do you mean replace $sText=FileRead by _IEBodyReadHTML?
AutoBert Posted October 14, 2016 Posted October 14, 2016 On 10/14/2016 at 1:22 PM, abdulrahmanok said: do you mean replace $sText=FileRead by _IEBodyReadHTML? Expand no i mean replace $sText=_IEBodyReadHTML($oIE). Like example in helpfile.
abdulrahmanok Posted October 14, 2016 Author Posted October 14, 2016 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
AutoBert Posted October 14, 2016 Posted October 14, 2016 You are mixing 2 difernetly ways to solve. If you would try my solution, than 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 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: IE_Snipet.txt abdulrahmanok 1
abdulrahmanok Posted October 14, 2016 Author Posted October 14, 2016 On 10/14/2016 at 1:59 PM, AutoBert said: You are mixing 2 difernetly ways to solve. If you would try my solution, than 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 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: IE_Snipet.txtFetching info... Expand 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]
abdulrahmanok Posted October 14, 2016 Author Posted October 14, 2016 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
AutoBert Posted October 14, 2016 Posted October 14, 2016 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 .
abdulrahmanok Posted October 14, 2016 Author Posted October 14, 2016 On 10/14/2016 at 7:27 PM, 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 . Expand Ty Again I Appreciate to you , I'm started to understand Arrays now a bit and I'm trying to read about it more .
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