NizonRox Posted November 19, 2013 Share Posted November 19, 2013 (edited) Ive just started playing around with autoit3 for a while.. and was wondering if i can find a line of text in the html, and execute a command fx. for checking if im logged in or logged out. Im using google chrome but im willing to use IE cause for what ive learned so far is thats what you guys use mostly. Im currently looking into Chrome UDF Plzz keep me updated if you find a way to do this Edited November 19, 2013 by NizonRox Link to comment Share on other sites More sharing options...
michaelslamet Posted November 19, 2013 Share Posted November 19, 2013 Hi NizonRox, With IE (ie.au3) you can doing something like: If StringInStr(_IEBodyReadText($oIE), "my text") Then ... EndIf Link to comment Share on other sites More sharing options...
NizonRox Posted November 20, 2013 Author Share Posted November 20, 2013 Error: Variable Used Without Being Declared.... Help? #include <IE.au3> HotKeySet ("{SPACE}", "Check") While 1 Sleep(100) WEnd Func Check () MouseClick ( "LEFT", 1046, 196, 1, 1) Sleep(500) If StringInStr(_IEBodyReadText($oIE), "Online") Then Exit EndIf If StringInStr(_IEBodyReadText($oIE), "Offline") Then Exit EndIf EndFunc Link to comment Share on other sites More sharing options...
l3ill Posted November 20, 2013 Share Posted November 20, 2013 (edited) Yep, you have to declare $oIE Local $oIE = _IECreate("www.autoitscript.com", 1) Edited November 20, 2013 by billo 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...
NizonRox Posted November 20, 2013 Author Share Posted November 20, 2013 If i use Local $oIE = _IECreate("www.autoitscript.com", 1) And go to "www.autoitscript.com/forum will the string find the pattern on autoitscript.com or on autoitscript.com/forum Link to comment Share on other sites More sharing options...
FlashpointBlack Posted November 20, 2013 Share Posted November 20, 2013 (edited) It will find it in whatever URL is loaded when you hit the hotkey combination. it's basically reading whatever is in IE at any given time, you're just telling it which IE window to look at and ignoring the possibility of further automation by using things like _IENavigate() something I just noticed though is that your source code does not do anything different if online is found or offline. not sure if that was a mistake or not... Something like this might work better: $HTML = _IEBodyReadText($oIE) If StringInStr($HTML, "Online") Then ;Code to execute if "Online" was found in the source of currently loaded website Elseif StringInStr($HTML, "Offline") Then ;Code to execute if "Offline" was found in the source of currently loaded website, and "Online" was not Else ;Code to execute if neither "Online" nor "Offline" were found. (An error of some sort, perhaps wrong site loaded) Exit EndIf in this example, I put the source code for the currently loaded website into a variable so you don't have to pull it from IE more than once. the way you had it, each time you checked if a string was found, the script communicated with IE again, causing a small slowdown. I also used "elseif" instead of two different If statements. This ensures that only one of the group will be true. In your example, if the loaded website contained both "Online" and "Offline" both sets of code would be executed. I removed the "exit" statement from the code to run. It seems strange that you would go to the trouble to set a hotkey just to have the program exit after it's been used once. without the "exit" code, the script is repeatable and you may continue to use the hotkey to activate the script. otherwise the hotkey just seems unneeded, if you could just run the script and exit when the code was finished. I've added a section for if neither Online or Offline was found as sort of an error catch, which has the exit in there. Just a few thoughts. Edited November 20, 2013 by FlashpointBlack Link to comment Share on other sites More sharing options...
NizonRox Posted November 20, 2013 Author Share Posted November 20, 2013 Thx. Thats rly what i needed, ill be looking into it and return if i got another problem Link to comment Share on other sites More sharing options...
jdelaney Posted November 20, 2013 Share Posted November 20, 2013 Rather than broadly looking for text, you should look for the div that holds the data, and get it's innertext...be sure that the text you are looking for is the actual expected state of your login. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. 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