If www.AnySite.com/AnyFile.html exists then
else
endif
Edited by LovinItAll, 28 February 2006 - 05:25 PM.
Posted 28 February 2006 - 05:21 PM
Edited by LovinItAll, 28 February 2006 - 05:25 PM.
Posted 28 February 2006 - 05:56 PM
Sure -- this should work...For instance, if I wanted to know if www.AnySite.com/AnyFile.html exists, is there a way to do this? Sort of like:
If www.AnySite.com/AnyFile.html exists then
else
endif
;Check existance of a URL ;adapted to AutoIt from <a href='http://www.developerfusion.co.uk/show/1605/' class='bbc_url' title='External link' rel='norewrite nofollow external'>http://www.developerfusion.co.uk/show/1605/</a> ;by DaleHohm ;Timeout values in milliseconds $ResolveTimeout = 500 $ConnectTimeout = 500 $SendTimeout = 500 $ReceiveTimeout = 500 $oHttpRequest = ObjCreate("MSXML2.ServerXMLHTTP") If $oHttpRequest = 0 Then ConsoleWrite("Error creating Object $oHttpRequest. " & _ "You must have 3.0 or later of the MSXML library to use this code" & @CR) EndIf $sTestUrl = "<a href='http://www.microsoft.com/nonexistingpage.html' class='bbc_url' title='External link' rel='norewrite nofollow external'>http://www.microsoft.com/nonexistingpage.html"</a> With $oHttpRequest .SetTimeouts ($ResolveTimeout, $ConnectTimeout, $SendTimeout, $ReceiveTimeout) .Open ("GET", $sTestUrl) .Send Select Case .Status = 200;No problem! ConsoleWrite($sTestUrl & " is a valid, available URL" & @CR) Case .Status = 404;Not found ConsoleWrite($sTestUrl & " could not be found (404 Error)" & @CR) Case Else;Some other problem ConsoleWrite("An unexpected HTTP Status value was returned: " & .Status & @CR) EndSelect EndWith $oHttpRequest = ""
Edited by DaleHohm, 28 February 2006 - 06:25 PM.
Posted 28 February 2006 - 06:23 PM
;Check existance of a URL ;adapted to AutoIt from <a href='http://www.developerfusion.co.uk/show/1605/' class='bbc_url' title='External link' rel='norewrite nofollow external'>http://www.developerfusion.co.uk/show/1605/</a> ;by DaleHohm ;Timeout values in milliseconds $ResolveTimeout = 500 $ConnectTimeout = 500 $SendTimeout = 500 $ReceiveTimeout = 500 ; Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $oHttpRequest = ObjCreate("MSXML2.ServerXMLHTTP") $sTestUrl = "<a href='http://www.microsoft.com/nonexistingpage.html' class='bbc_url' title='External link' rel='norewrite nofollow external'>http://www.microsoft.com/nonexistingpage.html"</a> ; With $oHttpRequest .SetTimeouts ($ResolveTimeout, $ConnectTimeout, $SendTimeout, $ReceiveTimeout) .Open ("GET", $sTestUrl) .Send Select Case .Status = 200;No problem! ConsoleWrite($sTestUrl & " is a valid, available URL" & @CR) Case .Status = 404;Not found ConsoleWrite($sTestUrl & " could not be found (404 Error)" & @CR) Case Else;Some other problem ConsoleWrite("An unexpected HTTP Status value was returned: " & .Status & @CR) EndSelect EndWith ; $oHttpRequest = "" ; ; Com Error Handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description,3) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1); something to check for when this function returns Return EndFunc ;==>MyErrFunc
Visit the SciTE4AutoIt3 Download page for the latest versions Forum Rules
Live for the present,
Dream of the future,
Learn from the past.
Posted 28 February 2006 - 06:30 PM
Sorry, there is a requirement for MSXML 3.0. JdeB's error handler is always a good idea (when you aren't being lazy like I was@DaleHohm,
I get:with that code...
Posted 28 February 2006 - 06:36 PM
Posted 28 February 2006 - 06:46 PM
Edit: Added check object creation and caveat about MSXML 3.0
If $oHttpRequest = 0 Then ConsoleWrite("Error creating Object $oHttpRequest. " & _ "You must have 3.0 or later of the MSXML library to use this code" & @CR) EndIf
Edit: So I guess that I have MSXML 3.0 installed and I still get the error above.>"C:\Program Files\AutoIt3\SciTe\CompileAU3\CompileAU3.exe" /run /beta /ErrorStdOut /in "c:\Temp\SciTE-temp.au3" /autoit3dir "C:\Program Files\AutoIt3\beta" /UserParams
>Running: (3.1.1.110):C:\Program Files\AutoIt3\beta\autoit3.exe "c:\Temp\SciTE-temp.au3"
C:\Temp\SciTE-temp.au3 (21) : ==> The requested action with this object has failed.:
.Send
.Send^ ERROR
>AutoIT3.exe ended.
>Exit code: 0 Time: 1.541
Edited by herewasplato, 28 February 2006 - 11:31 PM.
Posted 28 February 2006 - 06:47 PM
I am sorry, copied it from another script and forgot about the array..JdeB,
; Com Error Handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & StringStripWS($oMyError.description,3) & @LF) SetError(1); something to check for when this function returns Return EndFunc ;==>MyErrFunc
Edited by JdeB, 28 February 2006 - 06:47 PM.
Visit the SciTE4AutoIt3 Download page for the latest versions Forum Rules
Live for the present,
Dream of the future,
Learn from the past.
Posted 28 February 2006 - 06:52 PM
No problem. This is the output now:I am sorry, copied it from another script and forgot about the array..
>Running: (3.1.1.110):C:\Program Files\AutoIt3\beta\autoit3.exe "c:\Temp\SciTE-temp.au3"
### COM Error ! Number: 80020009 ScriptLine: 18 Description:The server name or address could not be resolved
### COM Error ! Number: 80020009 ScriptLine: 22 Description:The data necessary to complete this operation is not yet available.
An unexpected HTTP Status value was returned:
### COM Error ! Number: 80020009 ScriptLine: 25 Description:The data necessary to complete this operation is not yet available.
### COM Error ! Number: 80020009 ScriptLine: 25 Description:The data necessary to complete this operation is not yet available.
>AutoIT3.exe ended.
Edited by herewasplato, 28 February 2006 - 11:32 PM.
Posted 02 March 2006 - 06:10 PM
Here is a very good page about ServerXMLHTTP: Frequently asked questions about ServerXMLHTTP. One of the things it hilights is that ServerXMLHTTP does not do automatic proxy discovery and that you may have to run proxycfg.exe first... this would explain your trouble I believe.No problem. This is the output now:
Edit: Tested without a proxy server to the net - works fine.
Returns (404 Error) as expected.
Edited by DaleHohm, 02 March 2006 - 06:11 PM.
Posted 03 March 2006 - 11:51 AM
I tried this originally, but Ping will not detect the existence of folders within a URL. For example:????
Ping ( address or hostname [, timeout] )
When the function fails (returns 0) @error contains extended information:
1 = Host is offline
2 = Host is unreachable
3 = Bad destination
4 = Other errors
????
8)
Posted 06 March 2006 - 11:41 PM
Here is a very good page about ServerXMLHTTP: Frequently asked questions about ServerXMLHTTP. One of the things it hilights is that ServerXMLHTTP does not do automatic proxy discovery and that you may have to run proxycfg.exe first... this would explain your trouble I believe.
There is an older component called XMLHTTP that is also discussed in that article that does do automatic proxy detection. I believe it could also be used to do this discovery, but from my experience may need some additional error handling when used in AutoIt. I have not done any testing of this however.
Dale
Edit: fixed hyperlink
"Sometimes you have to go back to where you started, to get to where you want to go." MT"Everybody catches up with everyone, eventually" MT
How to ask a Question Forum SearchWIKI FAQ Tutorials Original FAQ - AutoIt Snippets - Multple Guis - Interrupting a running functionAnother Send StringRegExp StringRegExp Help RegEX TesterONLINE HELP UDF's Wiki AutoIt PDF AutoItSetOption Macros Wiki Arrays AutoIt Snippets WrapperAutoit Docs SCITE SciteJump - BB MyTopicsProgramming UDFs AutoIt_101 UDFs Form - UDFTutorial - Tutorials - Documentation - IE.AU3Games? - FreeSoftwarePath_Online
Posted 07 March 2006 - 12:49 AM
From above: "you may have to run proxycfg.exe first" -- see the FAQ referenced. Or use XMLHTTPRequest that does auto proxy discovery.Is there anyway to connect to a proxy ? - I would have server name or IP, username, password and would have the port numbeer.
Or has this question already been asked and answered?
Thanks
Posted 07 March 2006 - 03:22 AM
I read the information and it appears that you can grab the info from the registry for HKCU - is this correct? If that is the case I can write the info from there...to the HKLM without a reboot? Or would it be better to call this application from within the script, but then I would have to include it with the script as I am sure not everyone would have the proxycfg.exe installed - I had to download it. The reason for all this is I would like to be able to run programs like the ccweather.au3 at my work which has an proxy server (ISA).From above: "you may have to run proxycfg.exe first" -- see the FAQ referenced. Or use XMLHTTPRequest that does auto proxy discovery.
Dale
Edited by nitekram, 07 March 2006 - 03:25 AM.
"Sometimes you have to go back to where you started, to get to where you want to go." MT"Everybody catches up with everyone, eventually" MT
How to ask a Question Forum SearchWIKI FAQ Tutorials Original FAQ - AutoIt Snippets - Multple Guis - Interrupting a running functionAnother Send StringRegExp StringRegExp Help RegEX TesterONLINE HELP UDF's Wiki AutoIt PDF AutoItSetOption Macros Wiki Arrays AutoIt Snippets WrapperAutoit Docs SCITE SciteJump - BB MyTopicsProgramming UDFs AutoIt_101 UDFs Form - UDFTutorial - Tutorials - Documentation - IE.AU3Games? - FreeSoftwarePath_Online
0 members, 0 guests, 0 anonymous users