vampirevn01 Posted December 16, 2009 Posted December 16, 2009 I have a function: FUNC GETHTML($URLINPUT) $OHTTP=OBJCREATE("winhttp.winhttprequest.5.1") $OHTTP.Open("GET",$URLINPUT) $OHTTP.Send() $HTMLSOURCE=$OHTTP.Responsetext RETURN $HTMLSOURCE ENDFUNC I want this function return the string "Can't connect" when load fail but I don't known how to do that. When connect fail, autoit will says: --------------------------- AutoIt Error --------------------------- Line 2038 (File "D:\Vampire\Programs\Program\test.au3"): $OHTTP.Send() $OHTTP.Send()^ ERROR Error: The requested action with this object has failed. --------------------------- OK --------------------------- Please help me how to known when it connect fail.
Fire Posted December 16, 2009 Posted December 16, 2009 Try this: FUNC GETHTML($URLINPUT) $OHTTP=OBJCREATE("winhttp.winhttprequest.5.1") $OHTTP.Open("GET",$URLINPUT) $OHTTP.Send() if @error Then msgbox(64, "Cannot connect","Cannot Connect." & " or socket died!") Else $HTMLSOURCE=$OHTTP.Responsetext RETURN $HTMLSOURCE EndIf ENDFUNC [size="5"] [/size]
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