abdulrahmanok Posted October 14, 2016 Share 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 Link to comment Share on other sites More sharing options...
Muhammad_Awais_Sharif Posted October 14, 2016 Share Posted October 14, 2016 try this one bro Local $selectedday = _IEGetObjByName($oIE, "selected_day") MsgBox(0, "Value", $selectedday.value) Link to comment Share on other sites More sharing options...
l3ill Posted October 14, 2016 Share 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... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 14, 2016 Author Share Posted October 14, 2016 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 Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 14, 2016 Author Share Posted October 14, 2016 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 Link to comment Share on other sites More sharing options...
l3ill Posted October 14, 2016 Share Posted October 14, 2016 did you save your example text as test.txt works fine here... My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 14, 2016 Author Share Posted October 14, 2016 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 Link to comment Share on other sites More sharing options...
l3ill Posted October 14, 2016 Share Posted October 14, 2016 ??? you should get 5 consecutive msgbox's with the 5 dates. is that not happening? My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 14, 2016 Author Share Posted October 14, 2016 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") Link to comment Share on other sites More sharing options...
AutoBert Posted October 14, 2016 Share 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. 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 October 14, 2016 by AutoBert Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 14, 2016 Author Share Posted October 14, 2016 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? Link to comment Share on other sites More sharing options...
AutoBert Posted October 14, 2016 Share Posted October 14, 2016 Just now, abdulrahmanok said: do you mean replace $sText=FileRead by _IEBodyReadHTML? no i mean replace $sText=_IEBodyReadHTML($oIE). Like example in helpfile. Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 14, 2016 Author Share 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 Link to comment Share on other sites More sharing options...
AutoBert Posted October 14, 2016 Share 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 Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 14, 2016 Author Share Posted October 14, 2016 5 hours ago, 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.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] Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 14, 2016 Author Share 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 Link to comment Share on other sites More sharing options...
AutoBert Posted October 14, 2016 Share 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 . Link to comment Share on other sites More sharing options...
abdulrahmanok Posted October 14, 2016 Author Share Posted October 14, 2016 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 . Link to comment Share on other sites More sharing options...
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