Jack023 Posted December 1, 2013 Share Posted December 1, 2013 Hey all, I'm trying to read a text from my site. Only text there can be is On or Off and tryed to make a if statement with no luck site=: http://jackclania.netai.net/test2.php #include <IE.au3> $i = 1 Do sleep(3000) $oIE = _IECreate("http://jackclania.netai.net/test2.php", "", 0) $sHTML = _IEBodyReadText($oIE) MsgBox(0, "status", "status = " & $sHTML) If _IEBodyReadText($oIE) = "on" then Do MsgBox(0, "ON", "status = ON") $oIE = _IECreate("http://jackclania.netai.net/test2.php", "", 0) $sHTML = _IEBodyReadText($oIE) Until $sHTML = "off" ElseIf _IEBodyReadText($oIE) = "on" then Do MsgBox(0, "OFF", "status = OFF") $oIE = _IECreate("http://jackclania.netai.net/test2.php", "", 0) $sHTML = _IEBodyReadText($oIE) ProcessClose("iexplore.exe") MsgBox(0, "ON", "status = on") Until $sHTML = "on" EndIf Until $i = 0 Thanks in advance ) Link to comment Share on other sites More sharing options...
Valuater Posted December 1, 2013 Share Posted December 1, 2013 Maybe... #include <IE.au3> $oIE = _IECreate("http://jackclania.netai.net/test2.php");, "", 0) HotKeySet("{ESC}", "Terminate") While 1 Sleep(3000) $sHTML = _IEBodyReadText($oIE) MsgBox(0, "status", "status = *" & $sHTML & "*"); note there is a return in here If StringInStr($sHTML, "on") Then MsgBox(0, "ON", "status = ON") _IENavigate($oIE, "http://jackclania.netai.net/test2.php?set=off") Else MsgBox(0, "OFF", "status = OFF") _IENavigate($oIE, "http://jackclania.netai.net/test2.php?set=on") EndIf WEnd Func Terminate() _IEQuit($oIE) Exit 0 EndFunc ;==>Terminate Link to comment Share on other sites More sharing options...
Jack023 Posted December 1, 2013 Author Share Posted December 1, 2013 (edited) works good, only the _ienavigate was not needed. Only i want that after it checked like if it's on, it keeps checking it untill its OFF and then restart the previous loop again. It's now like this: #include <IE.au3> $oIE = _IECreate("http://jackclania.netai.net/test2.php", "", 0);, "", 0) HotKeySet("{ESC}", "Terminate") While 1 sleep(3000) $sHTML = _IEBodyReadText($oIE) MsgBox(0, "status", "status = *" & $sHTML & "*"); note there is a return in here If StringInStr($sHTML, "on") Then MsgBox(0, "ON", "status = ON") ;~ _IENavigate($oIE, "http://jackclania.netai.net/test2.php?set=off") Else MsgBox(0, "OFF", "status = OFF") ;~ _IENavigate($oIE, "http://jackclania.netai.net/test2.php?set=on") EndIf WEnd Func Terminate() _IEQuit($oIE) Exit 0 EndFunc ;==>Terminate Edited December 1, 2013 by Jack023 Link to comment Share on other sites More sharing options...
Jack023 Posted December 2, 2013 Author Share Posted December 2, 2013 bump Link to comment Share on other sites More sharing options...
Jack023 Posted December 4, 2013 Author Share Posted December 4, 2013 Nobody knows? Lol Link to comment Share on other sites More sharing options...
Jack023 Posted December 5, 2013 Author Share Posted December 5, 2013 Hey all, I'm trying to understand how winhttp works. I'm trying to read the text on this page , can be on or off. but want this in a loop. http://jackclania.netai.net/status // this is the site where you need read from. Tried many things but nothing works, any tips? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 5, 2013 Moderators Share Posted December 5, 2013 Tip #1: Post your code. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
kylomas Posted December 5, 2013 Share Posted December 5, 2013 He did,> here... @Jack023 - Stick to one thread. If you are not getting Help it is either because you have not posted enough info or expertise is not available. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Jack023 Posted December 5, 2013 Author Share Posted December 5, 2013 Well , it was meant to that thread, but found out that winhttp is better then IE.au3 , so thats why i came here, will post new code her soon Link to comment Share on other sites More sharing options...
Jack023 Posted December 5, 2013 Author Share Posted December 5, 2013 #include "WinHttp.au3" $text = 0 // when i removed this it gave a error. Opt("MustDeclareVars", 1) ; Initialize and get session handle Global $hOpen = _WinHttpOpen() ; Get connection handle Global $hConnect = _WinHttpConnect($hOpen, "http://jackclania.netai.net/status") $text = _WinHttpSimpleRequest($hConnect, "GET", "http://jackclania.netai.net/status") MsgBox(0, "", $text) ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) but what i need is read if it's on or off on the page http://jackclania.netai.net/status Link to comment Share on other sites More sharing options...
mikell Posted December 5, 2013 Share Posted December 5, 2013 There are several ways $url = "http://jackclania.netai.net/status" $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") ; or : ; $oHTTP = ObjCreate("Microsoft.XMLHTTP") $oHTTP.Open("GET", $url, 0) $oHTTP.Send() Local $txt = $oHTTP.Responsetext $oHTTP = 0 Msgbox(0,"", $txt) ; else Msgbox(0,"", BinaryToString(InetRead($url, 1))) or _InetGetSource, etc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 5, 2013 Moderators Share Posted December 5, 2013 Jack023,Threads merged - please stick to just the one at a time in future. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Jack023 Posted December 5, 2013 Author Share Posted December 5, 2013 #include "WinHttp.au3" $text = 0 Opt("MustDeclareVars", 1) ; Initialize and get session handle Global $hOpen = _WinHttpOpen() ; Get connection handle Global $hConnect = _WinHttpConnect($hOpen, "http://jackclania.netai.net/status") $text = _WinHttpSimpleRequest($hConnect, "GET", "http://jackclania.netai.net/status") MsgBox(0, "", $text) ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Alright, i heard that i could use winhttp instead of IE. So i try to read on the page: http://jackclania.netai.net/status if the message is ON or off , it can be both. I want this in a loop but the script above dont work. Greets, Jack Link to comment Share on other sites More sharing options...
Jack023 Posted December 5, 2013 Author Share Posted December 5, 2013 (edited) $url = "http://jackclania.netai.net/status" $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") ; or : ; $oHTTP = ObjCreate("Microsoft.XMLHTTP") $oHTTP.Open("GET", $url, 0) $oHTTP.Send() Local $txt = $oHTTP.Responsetext $oHTTP = 0 Msgbox(0,"", $txt) ; else Msgbox(0,"", BinaryToString(InetRead($url, 1))) worked fine for me, thanks ! Does it also work when the pc don't have internet explorer? Edited December 5, 2013 by Jack023 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 5, 2013 Moderators Share Posted December 5, 2013 Do you mean another default browser? Have you tried it? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Jack023 Posted December 5, 2013 Author Share Posted December 5, 2013 Well it just works for now as i wanted. Huge thanks !! only my question was, what if the pc dont have internet explorer. Does it still work then? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 5, 2013 Moderators Share Posted December 5, 2013 And as I asked before, you need to clarify what you mean by "don't have internet explorer". Do you mean when the person is using a different browser, or has internet explorer actually been disabled altogether? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Jack023 Posted December 6, 2013 Author Share Posted December 6, 2013 When they are not able to surf using ANY browser , like they dont have IE, Chrome and Firefox at all. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 6, 2013 Moderators Share Posted December 6, 2013 Still trying to understand under what circumstance you would have a user in that situation. It takes a lot to disable all web browsers on a Windows machine. My question from post #15 still stands; since you obviously have a specific scenario in mind, have you tried to duplicate it yourself? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Jack023 Posted December 6, 2013 Author Share Posted December 6, 2013 Well it's alright ! This thread is done for me ! 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