ffiso Posted April 4, 2009 Posted April 4, 2009 Hi!!! I have a little problem, maybe you can help me out I have already used the search.. but no luck... the problem is that i'm unable to find the position of a substring using StringInStr, below is the code I'm Using, so here a little explanation I'm looking for the text 'equiv="C', but StringInStr always returns a 0 instead of a 104... if I look for 'equiv=' Success! (but I also need the part after the equal sign) if I look for '="' Success! (but not the position I'm looking for) if I look for '="C' it fails.... (but I also need the part before the equal sign) It seems that the function doesn't like the Equal + Quote sign and a letter before or after... This is all an example, the actual code is trying to look for some specific tags, but that's the main problem, can't use it loading the source code into a String... but if I write the source code directly into the autoit code everything works fine... but of course that's impossible if I want to look into a page that updates constantly... Thanks for your help!!! This code doesn't work #include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> _IEErrorHandlerRegister() $oIE = _IECreateEmbedded() $GUI = GUICreate("Titulo", 800, 500, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 815, 465) GUISetState() _IENavigate($oIE, "http://www.autoitscript.com/") $codigoFuente = _IEDocReadHTML($oIE) $pos = StringInStr($codigoFuente, 'equiv="C') MsgBox(0, "", $pos) ---------------------------------------------- this code works..., but as you can see, the String where the function looks is within the code.... #include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> _IEErrorHandlerRegister() $oIE = _IECreateEmbedded() $origen = '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">' $GUI = GUICreate("Titulo", 800, 500, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 815, 465) GUISetState() _IENavigate($oIE, "http://www.autoitscript.com/") $pos = StringInStr($origen, 'equiv="C') MsgBox(0, "", $pos)
Developers Jos Posted April 4, 2009 Developers Posted April 4, 2009 Have you looked at the source?<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type><LINK rel=stylesheet type=text/css href="css/default.css"><LINK rel=stylesheet type=text/css href="css/default_ie.css"></HEAD>I don't see the doubleQuote. 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.
Moderators SmOke_N Posted April 4, 2009 Moderators Posted April 4, 2009 (edited) The "simple" answer is, there is no equiv=C in the source code. Edit: Seems Jos beat me, but I copied to clipboard, and I don't have equiv= anything. Edited April 4, 2009 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Exit Posted April 4, 2009 Posted April 4, 2009 This works for me: #include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> _IEErrorHandlerRegister() $oIE = _IECreateEmbedded() $GUI = GUICreate("Titulo", 800, 500, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 815, 465) GUISetState() _IENavigate($oIE, "http://www.autoitscript.com/") $codigoFuente = _IEDocReadHTML($oIE) $pos = StringInStr($codigoFuente, 'equiv=C') ConsoleWrite($codigoFuente) MsgBox(0+262144, "", $pos) Result is 64. App: Au3toCmd UDF: _SingleScript()
ffiso Posted April 4, 2009 Author Posted April 4, 2009 Have you looked at the source? I don't see the doubleQuote. OOOOK... Then there's something weird.... How you did that???, because I DO see the double quote in the source code (from firefox and from IExplorer).... maybe I should have looked in the String xD Sorry never thought of analyzing the String instead of the "View Source Code" option in the explorers.... Yep, I just did... they're different (The string and the view source code option) This works for me: #include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> _IEErrorHandlerRegister() $oIE = _IECreateEmbedded() $GUI = GUICreate("Titulo", 800, 500, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 815, 465) GUISetState() _IENavigate($oIE, "http://www.autoitscript.com/") $codigoFuente = _IEDocReadHTML($oIE) $pos = StringInStr($codigoFuente, 'equiv=C') ConsoleWrite($codigoFuente) MsgBox(0+262144, "", $pos) Result is 64. Thanks to all of you though the result for me is 104, not 64 :|..... Thanks!!!
Developers Jos Posted April 4, 2009 Developers Posted April 4, 2009 (edited) OOOOK... Then there's something weird.... How you did that???, because I DO see the double quote in the source code (from firefox and from IExplorer).... maybe I should have looked in the String xDWhat I always do in these cases is an Alt+D on the variable I want to know the exact value (assuming you have the full SciTE4AutoIT3) which will add a Debug line for you. Then hit F5 and look in the Outputpane of SciTE. Jos Edited April 4, 2009 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.
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